0

I want when a user buys an nft, 90% of the amount goes to the author and 10% to the marketplace.

When I deploy my smart contract everything works fine: https://legacy.smartpy.io/ide?cid=QmWDHLWSQYKJSRPbvLWqPc41BZtJ8X7svQgEDnrtckQiHt&k=d5825d30041e66cfc3a4

When I call the smart contract function in react js:

export const collectNFT = ({ Tezos, amount, id, author }) => {
  return async (dispatch) => {
    try {
      const contract = await Tezos.wallet.at(config.contractAddress);
      const op = await contract.methods
        .collect(id)
        .send({ mutez: true, amount: amount });
      await op.confirmation();
      dispatch(fetchData());
    } catch (e) {
      console.log(e);
    }
  };
};

I get an error when confirming on my wallet:

{
  "error": [
    {
      "errors": [
        {
          "kind": "temporary",
          "id": "proto.016-PtMumbai.michelson_v1.runtime_error",
          "contract_handle": "KT1JB3JUsvwxrHc6W93ZpWwkKSD3xQGy7waL",
          "contract_code": "Deprecated"
        },
        {
          "kind": "temporary",
          "id": "proto.016-PtMumbai.michelson_v1.script_rejected",
          "location": 152,
          "with": {
            "int": "83"
          }
        }
      ],
      "errorDetails": "Error occurred during estimation",
      "name": "TezosOperationError",
      "id": "proto.016-PtMumbai.michelson_v1.script_rejected",
      "kind": "temporary",
      "message": "83",
      "isError": true
    },
    {
      "errors": [
        {
          "kind": "temporary",
          "id": "proto.016-PtMumbai.michelson_v1.runtime_error",
          "contract_handle": "KT1JB3JUsvwxrHc6W93ZpWwkKSD3xQGy7waL",
          "contract_code": "Deprecated"
        },
        {
          "kind": "temporary",
          "id": "proto.016-PtMumbai.michelson_v1.script_rejected",
          "location": 152,
          "with": {
            "int": "83"
          }
        }
      ],
      "errorDetails": "Error occurred during estimation",
      "name": "TezosOperationError",
      "id": "proto.016-PtMumbai.michelson_v1.script_rejected",
      "kind": "temporary",
      "message": "83",
      "isError": true
    }
  ]
}

I would like to know where my error comes from and why. Thank you!

1 Answer 1

0

I found my error, it was necessary to put an empty field in "entry_point"

token_contract = sp.contract(sp.TUnit, self.data.data[params.token_id].author, entry_point="").open_some()

marketplace_contract = sp.contract(sp.TUnit, self.data.admin, entry_point="").open_some()

Don't forget to put yourself as admin to receive the 10%

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.