안녕하세요. ERC6551 테스트를 진행하다가 궁금한게 생겨서 왔습니다.
TBA를 생성하고 그 TBA에 ERC20토큰을 전송하고 1토큰을 다른 지갑으로 전송하는 예제를 만들고 있습니다.
"0xf1b31d84f61020f40efc143e0ecba4669f6e6a736acb2f9a694f7251a6ca4123"로 Tx는 성공했는데 1토큰이 전송이 안되었네요
Function function = new Function(
"transfer",
Arrays.asList(new Address(toAddress), new Uint256(amount)),
Arrays.asList(new TypeReference<Type>() {}));
String encodedFunction = FunctionEncoder.encode(function);
byte[] encodedFunctionArray = Numeric.hexStringToByteArray(encodedFunction);
KlayCredentials credentials = KlayCredentials.create(testPrivateKey);
AbstractKeyring fromKeyring = TokenUtils.createFromPrivateKey(testPrivateKey);
KlayCredentials feePayerCredentials = KlayCredentials.create(feePayerPrivateKey);
BigInteger nonce = web3j.ethGetTransactionCount(credentials.getAddress(), DefaultBlockParameterName.LATEST).send().getTransactionCount();
TxType.Type type = TxType.Type.FEE_DELEGATED_SMART_CONTRACT_EXECUTION;
KlayRawTransaction klayRawTransaction = KlayRawTransaction.createTransaction(
type,
nonce,
BigInteger.valueOf(50000000000L),
BigInteger.valueOf(6721950),
ERC20ContractAddress,
BigInteger.ZERO, // Klay
credentials.getAddress(), // from
encodedFunctionArray // ERC20 Transfer Function
);
// Sign as Sender
byte[] signMessage = KlayTransactionEncoder.signMessage(klayRawTransaction, chainId, credentials);
// Sign sa Feepayer
signMessage = KlayTransactionEncoder.signMessageAsFeePayer(klayRawTransaction, chainId, feePayerCredentials);
com.klaytn.caver.methods.response.TransactionReceipt.TransactionReceiptData transactionReceipt = erc6551AccountSandBox.execute(fromKeyring, toAddress, BigInteger.ZERO, signMessage, BigInteger.ONE);
소스는 이렇게 작성해서 거래를 발생시켰고
function execute(
address to,
uint256 value,
bytes calldata data,
uint256 operation
) external payable returns (bytes memory result) {
require(_isValidSigner(msg.sender), "Invalid signer");
++state;
bool success;
if(operation == OP_CALL) {
(success, result) = to.call{value: value}(data);
}
if(operation == OP_DELEGATECALL) {
address sandbox = LibSandbox.sandbox(address(this));
if (sandbox.code.length == 0) LibSandbox.deploy(address(this));
(success, result) = _call(sandbox, value, abi.encodePacked(to, data));
}
if (!success) {
assembly {
revert(add(result, 32), mload(result))
}
}
}
execute부분은 이렇게 작성해서 배포했었습니다
Delegatecall을 사용하면 다른 컨트랙트의 메소드를 실행할 수 있다고 해서 구현했는데
어느 부분이 잘못된건지 문의드립니다.