0

When I transfer the token from the contract address: KT1LkNWZgVYh3zdaRkBb9aNgLEFCjVJwEKu2, it works well. However, when I switch back to the address KT1P8RdJ5MfHMK5phKJ5JsfNfask5v2b2NQS, an issue occurs. Below is my code:

const { TezosToolkit } = require ('@taquito/taquito');
const { InMemorySigner } = require ('@taquito/signer');


const Tezos = new TezosToolkit('https://ghostnet.ecadinfra.com/');
Tezos.setProvider({
  signer: new InMemorySigner('edskRpi3j2hwiRqRvjoETUe99L14Kz796pLS3N6rq6K3sLC9Xq2BY27KhTFtAUtkgEwacZWvsFaJ6Cnju2EWNYSEJkhDSwjGzf'),
});
var from = "tz1MSint56iUqoogrKsvEMEykpbKv2Yhmzss"
var to  = "tz1S2aWw5Jhz7RBcAKvJYfAG82Mv9LhEUobc"
var amount = 99
async function tranfer(){

const contract = await Tezos.contract.at('KT1P8RdJ5MfHMK5phKJ5JsfNfask5v2b2NQS');
await contract.methods.transfer([{ 
  from_: from, 
  txs: [{ to_: to, token_id: 0, amount: amount }] 
}]).send();

 }
tranfer()

The error I encounter is:

AddressValidationError: [from] Address is not valid: [{"from_":"tz1MSint56iUqoogrKsvEMEykpbKv2Yhmzss","txs":[{"to_":"tz1S2aWw5Jhz7RBcAKvJYfAG82Mv9LhEUobc","token_id":0,"amount":99}]}]

2 Answers 2

1

This is happening because both contracts have different parameter schema for the transfer entrypoint.

Goto KT1LkNWZgVYh3zdaRkBb9aNgLEFCjVJwEKu2 TzKt, the arguments should be in the format:

"schema:list:object": [
    {
        "from_:address": "address",
        "txs:list:object": [
            {
                "to_:address": "address",
                "token_id:nat": "nat",
                "amount:nat": "nat"
            }
        ]
    }
]

Goto KT1P8RdJ5MfHMK5phKJ5JsfNfask5v2b2NQS TzKt, the arguments should be in the format:

"schema:object": {
    "from:address": "address",
    "to:address": "address",
    "value:nat": "nat"
}

So, for the other contract you should call it like this:

await contract.methods.transfer(from, to, amount).send();

Note that the order of the argument should be same as in the schema, that is from, to, amount.

0

If the only thing you change is the contract address, the second contract's transfer entrypoint has a different set of parameter names. The first one expects from_, while the second one expects from. Are you adjusting the parameter names properly?

2
  • That’s right, I only changed the contract address, the sender and recipient addresses remain the same, and the sender still has the new token balance of the contract.
    – Solider
    Nov 21 at 2:56
  • Please let me know if updating the parameter names fixes the problem
    – Alireza
    Nov 21 at 7:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.