This is the code I am testing which I got from petra docs.
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"
}
I expected it work without any error since i got it from docs, but I am wrong. I only added the address in arguments.
The error which I am seeing is
Transaction error
TYPE_RESOLUTION_FAILURE
What is cauing this error and How to solve it?
Likely the problem is 0x1::aptos_coin::TestCoin
. It is failing to resolve that type because that type doesn't exist on testnet, see aptos_coin
here: https://explorer.aptoslabs.com/account/0x1/modules. Instead you want 0x1::aptos_coin::AptosCoin
.
I see that your code came from these docs here: https://petra.app/docs/sending-a-transaction. I'll chat with the team to get these updated, 0x1::aptos_coin::TestCoin
was removed a long time ago.