Gnosis-Safe
通過 SDK 從 Gnosis Safe 中傳輸 POAP (ERC-721)
我正在使用 JS SDK 並嘗試創建一個傳輸出保險箱 POAP 的事務… tx 通過,我可以在 UI 中看到它,但不確定為什麼它不將資產傳輸出去保險箱的歷史與我送出的 txs 嘗試將 POAP 轉移出去 https://gnosis-safe.io/app/gno:0x166fe3B49E82c0514689Ff0527Cd7C76261A9D07/transactions/history
這是程式碼:
const transferPOAP = async (safeAddress: string, toAddress: string) => { // NOTE :: Get POAPs in wallet const poaps = await getWalletPOAPs(safeAddress); // NOTE :: Get array of POAP Token IDs const tokenIds = poaps.map((el) => el.tokenId); // NOTE :: Create Gnosis Safe Factory const safeSDK: Safe = await Safe.create({ ethAdapter: new EthersAdapter({ ethers, signer: owner_wallet, // NOTE :: Owner of safe }), safeAddress, }); // NOTE :: ABI encoded transaction data const data = web3.eth.abi.encodeFunctionCall( { name: "safeTransferFrom", type: "function", inputs: [ { type: "address", name: "from" }, { type: "address", name: "to" }, { type: "uint256", name: "tokenId" }, ], }, [safeAddress, toAddress, tokenIds[0]] ); // NOTE :: Create transaction const safeTransaction = await safeSDK.createTransaction({ safeTransactionData : { to: toAddress, value: "0", data, }, }); // NOTE :: Get transaction hash const txHash = await safeSDK.getTransactionHash(safeTransaction); // NOTE :: Sign + Execute transaction const executeTxResponse = await safeSDK.executeTransaction( safeTransaction ); // NOTE :: Get final confirmation of successful transaction const res = await executeTxResponse.transactionResponse?.wait(); console.log(res?.transactionHash); }
查看您保險箱上的最新交易條目,您似乎正試圖在地址0x9bE27356765EA765F1503c9c63e227fAD8c0B8A9上進行合約呼叫,這是一個 EOA。
要呼叫智能合約,您當然必須在合約(支持該方法)上執行它們。查看分配給安全地址的代幣,似乎有問題的 POAP 代幣合約是0x22C1f6050E56d2876009903609a2cC3fEf83B415。
因此,再次送出您的交易,但要確保“to”欄位(即您要與之互動的合約)是該合約。