我在这里使用gnosis安全核心SDK创建事务,将Eth从已部署的安全代理中传输出去。医生:https://github.com/safe-global/safe-core-sdk/tree/main/packages/safe-core-sdk#deploysafe
我在Rinkeby上部署了代理:
const { ethereum } = window;
const provider = new ethers.providers.Web3Provider(ethereum)
const safeOwner = provider.getSigner(0)
const ethAdapter = new EthersAdapter({ ethers, signer: safeOwner });
const txServiceUrl = 'https://safe-transaction.gnosis.io';
const safeService = new SafeServiceClient({ txServiceUrl, ethAdapter });
const is_dev = true;
let ethAdapter = this.ethAdapter;
const safeFactory = await SafeFactory.create({ ethAdapter, isL1SafeMasterCopy: !is_dev });
const safeAccountConfig = {
owners: ['0x...D9'],
threshold: 1,
}
const safeSdk = await safeFactory.deploySafe({ safeAccountConfig }); 所以这是一个只有一个授权人的保险箱。然后,我将一些ETH存入这个安全代理中,并尝试将其从保险箱中发送出去:
let safeAddress = '0x...c';
const safeSdk = await Safe.create({ ethAdapter, safeAddress, isL1SafeMasterCopy: false })
const num_ethers = ethers.utils.parseUnits("0.1", 'ether').toHexString();
const transaction = {
to: '0x...1',
data: '0x',
value:num_ethers,
}
const safeTransaction = await safeSdk.createTransaction(transaction)
console.log('safeTransaction: ', safeTransaction)
const hash = await safeSdk.getTransactionHash(safeTransaction);
const txResponse = await safeSdk.approveTransactionHash(hash);
const reshash = await txResponse.transactionResponse?.wait(); 最终发生的情况是,授权程序负责ApproveHash事务,但Eth不传输。我在这里有什么概念上的缺失吗?在Rinkeby网络上传输eth的数据字段也应该是0x,对吗?这里的Tx日志:https://rinkeby.etherscan.io/address/0x99Ae62C23728EAa970F5064DcD3F869ae80FC89c
发布于 2022-07-06 06:58:16
approveTransactionHash只批准事务而不执行它。请参阅核心SDK文档,以了解如何执行事务https://github.com/safe-global/safe-core-sdk/blob/main/packages/guides/integrating-the-safe-core-sdk.md#8-execute-the-transaction。
https://ethereum.stackexchange.com/questions/131256
复制相似问题