invalid token index when issuing token

205 Views Asked by At

After deploy a NFT smart contract on Elrond Blockchain, I'm trying to issueToken using snippets:

  erdpy --verbose contract call ${ADDRESS} --recall-nonce --pem=${ALICE} --gas-limit=${GAS_LIMIT} \
    --function="issueToken" \
    --value ${MINT_COST} \
    --arguments ${ISSUE_TOKEN_ARGUMENTS} \
    --proxy=${PROXY} --chain=${CHAINID} --send \
    --outfile="${MY_LOGS}/issueToken.json"
}

but I get the error "invalid token index"

2

There are 2 best solutions below

2
On

Since the token issue is managed by the smart contract you're calling (because you are calling the issueToken endpoint of that contract), the most likely cause is that you're not passing the correct parameters to the issueToken endpoint.

You have to know first what parameters does your contract expect for that endpoint, then pass them hex encoded according to the expected format.

For your specific case, if the endpoint signature looks like this:

#[only_owner]
#[payable("EGLD")]
#[endpoint(issueToken)]
fn issue_token(
    &self,
    #[payment] issue_cost: BigUint,
    token_name: ManagedBuffer,
    token_ticker: ManagedBuffer,
) -> SCResult<AsyncCall>

then the $ISSUE_TOKEN_ARGUMENTS should contain something like this:

ISSUE_TOKEN_ARGUMENTS="str:MyTokenName str:MYTKNTICKER"
0
On

Here is the issueToken endpoint

#[only_owner]
    #[payable("EGLD")]
    #[endpoint(issueToken)]
    fn issue_token(
        &self,
        #[payment] issue_cost: BigUint,
        token_name: ManagedBuffer,
        token_ticker: ManagedBuffer,
    ) -> SCResult<AsyncCall> {
        require!(self.nft_token_id().is_empty(), "Token already issued");

        Ok(self
            .send()
            .esdt_system_sc_proxy()
            .issue_non_fungible(
                issue_cost,
                &token_name,
                &token_ticker,
                NonFungibleTokenProperties {
                    can_freeze: true,
                    can_wipe: true,
                    can_pause: true,
                    can_change_owner: false,
                    can_upgrade: false,
                    can_add_special_roles: true,
                },
            )
            .async_call()
            .with_callback(self.callbacks().issue_callback()))
    }