클레이튼 sdk 로 이벤트 로그 어떻게 가져 오면 좋을가요?어디 에이피아이 참조하면 좋을까요?

안녕하세요
클레이튼에서 java sdk 기반으로 트렌젝션 리십트의 이벤트 로그를 가져오려고합니다.

TransactionReceiptData data=cavercaver.rpc.klay.getTransactionReceipt(txhahs).send().getResult();
List logs=data.getLogs();

해당 로그를 클레이 스코프로 보는 이벤트 로그 포멧으로 변환하고싶은데
어딜 참조해야 할지 알려주시면 고맙겠습니다.

안녕하세요.

caver-java의 ABI.decodeLog() 함수를 참고부탁드립니다.

해당함수는 Log를 디코딩하기위한 Event의 파라미터 정보가 필요합니다. 아래 코드 예시 참고바랍니다.

//Contract 인스턴스내 저장된 ContractEvent의 객체를 이용하셔도 됩니다.
List<ContractIOType> ioTypeList= Arrays.asList(
                    new ContractIOType("from", "address", true),
                    new ContractIOType("to", "address", true),
                    new ContractIOType("value", "uint256", false)
            );

List<String> topics = Arrays.asList(
                    "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
                    "0x0000000000000000000000000000000000000000000000000000000000000000",
                    "0x0000000000000000000000002c8ad0ea2e0781db8b8c9242e07de3a5beabb71a"
);

String nonIndexedData = "0x00000000000000000000000000000000000000000000152d02c7e14af6800000";

BigInteger decimals = BigInteger.valueOf(18);
BigInteger value = BigInteger.valueOf(100_000).multiply(BigInteger.TEN.pow(decimals.intValue())); // 100000 * 10^18

EventValues eventValues = caver.abi.decodeLog(ioTypeList, nonIndexedData, topics);

감사합니다.

1개의 좋아요

감사합니다~ 많은 참조가 되었습니다~