Std::token::mint_to causing weird Revert(18446744073709486081)

I am writing a token contract. it has a mint function. I test this function with rusk test. however, my test reverts with RevertTransactionError("Revert(18446744073709486081)"

    #[storage(read, write)]
    fn mint(recipient: Identity, amount: u64) {
        _validate_owner();
        storage.total_supply += amount;
        mint_to(amount, recipient);
        log(Mint{
            recipient: recipient.into(),
            amount: amount,
        })
    }

I manager to narrow down the error to the code mint_to(amount, recipient)
The contract method call went well if I remove the mint_to(amount, recipient) code in sway contract.

And the test pass if i replace it with the std::token::mint method.
this token mint_to causes this weird revert.

full RevertTransactionError log

 value: RevertTransactionError("Revert(18446744073709486081)", [Call { id: 0000000000000000000000000000000000000000000000000000000000000000, to: 526cd95eb58b14926a8a9b07178738dae8cae311326b7735e11a21573fb5ca72, amount: 0, asset_id: 0000000000000000000000000000000000000000000000000000000000000000, gas: 1000000, param1: 2713791341, param2: 10472, pc: 11680, is: 11680 }, Revert { id: 526cd95eb58b14926a8a9b07178738dae8cae311326b7735e11a21573fb5ca72, ra: 18446744073709486081, pc: 16952, is: 11680 }, ScriptResult { result: Revert, gas_used: 44827 }])

full code

3 Likes

This generally indicates that there is no available Variable Output to send the assets to. The solution is to either call append_variable_outputs in the SDK when calling the contract method above, or simply use the estimation methods which will do this for you.

4 Likes

thank you! let me try this out

thank you! append_variable_outputs works

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.