1

I'm trying to transfer an NFT, that I just minted to someone without them paying for it (just like an exchange). Here is the function I created on smartpy:

@sp.entry_point
def transferTest(self, params):
        sp.verify(self.data.data[params.token_id].collectable, "NotCollectable")
        sp.verify(self.data.data[params.token_id].author != sp.sender, "SenderNotAuthor")
        self.data.data[params.token_id].collectable = True
        self.data.data[params.token_id].holder = sp.sender

The code in the test function:

marketplace.transferTest(token_id=1).run(sender=elon.address)

Here is the complete smart contract: https://legacy.smartpy.io/ide?cid=QmSGKqymMBSLHADF5GC9nzqSNikwuFYcT2ZUwjaTzsyxWP&k=893cdae17d61921e246b

On smartpy everything works fine, now when I want to call the function in React JS:

  export const transferTokens = ({ Tezos, id, to }) => {
    return async (dispatch) => {
      try {
        const contract = await Tezos.wallet.at(config.contractAddress);

        
        const operation = await contract.methods.transferTest(id)
        .send({ sender: to });

      await operation.confirmation();

        dispatch(fetchData());
      } catch (e) {
        console.log(e);
      }
    };
  };

I get this error:

{
"error":[
0:{
"errors":[...]
"errorDetails":"Error occurred during estimation"
"name":"TezosOperationError"
"id":"proto.016-PtMumbai.michelson_v1.scri..."
"kind":"temporary"
"message":"SenderNotAuthor"
"isError":true
}
1:{
"errors":[...]
"errorDetails":"Error occurred during estimation"
"name":"TezosOperationError"
"id":"proto.016-PtMumbai.michelson_v1.scri..."
"kind":"temporary"
"message":"SenderNotAuthor"
"isError":true
}
]
"contents":undefined
}

I hope you could help me! THANKS

1 Answer 1

1

I managed to do the manipulation, here is the code of the smartcontract:

@sp.entry_point
def transferTest(self, params):
        sp.verify(self.data.data[params.token_id].collectable, "NotCollectable")
        sp.verify(self.data.data[params.token_id].holder == sp.sender, "NotAuthor")
        self.data.data[params.token_id].holder = params.to

Test code:

 scenario.h1("Transfert Elon")
 marketplace.transferTest(token_id=1, to=mark.address).run(sender=elon)

And my code (ReactJS):

const transferOperation = await contract.methods.transferTest(senderAddress, tokenId)
      .send();
      
await transferOperation.confirmation();

Your Answer

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

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