这是我从petra文档中得到的测试代码。
const wallet = getAptosWallet(); // see "Connecting"
// Example Transaction, following an [EntryFunctionPayload](https://github.com/aptos-labs/aptos-core/blob/main/ecosystem/typescript/sdk/src/generated/models/EntryFunctionPayload.ts#L8-L21)
const transaction = {
arguments: [address, '717'],
function: '0x1::coin::transfer',
type: 'entry_function_payload',
type_arguments: ['0x1::aptos_coin::TestCoin'],
};
try {
const pendingTransaction = await(
window as any,
).aptos.signAndSubmitTransaction(transaction);
// In most cases a dApp will want to wait for the transaction, in these cases you can use the typescript sdk
const client = new AptosClient('https://testnet.aptoslabs.com');
const txn = await client.waitForTransactionWithResult(
pendingTransaction.hash,
);
} catch (error) {
// see "Errors"
}
我期望它的工作没有任何错误,因为我得到了它从文档,但我错了。我只在参数中添加了地址。
我看到的错误是Transaction error
TYPE_RESOLUTION_FAILURE
是什么导致这个错误,如何解决它?
问题可能是0x1::aptos_coin::TestCoin
。它无法解析该类型,因为该类型不存在于测试网络上,见aptos_coin
这里:https://explorer.aptoslabs.com/account/0x1/modules。而应该是0x1::aptos_coin::AptosCoin
。
我看到你的代码来自这些文档:https://petra.app/docs/sending-a-transaction。我将和团队讨论这些更新,0x1::aptos_coin::TestCoin
很早以前就被删除了。