rustmultiversx

issue_and_set_all_roles responds with "token name is not human readable"


I have a smart contract function that internally calls issue_and_set_all_roles to issue an SFT and set all the roles, but it responds with "token name is not human readable" no matter the token name.

Smart contract function:

  #[only_owner]
  #[payable("EGLD")]
  #[endpoint]
  fn initiate_sft(
    &self,
    #[payment] issue_cost: BigUint<Self::Api>,
    token_display_name: ManagedBuffer<Self::Api>,
    token_ticker: ManagedBuffer<Self::Api>,
  ) {
    let caller = self.blockchain().get_caller();

    self
      .send()
      .esdt_system_sc_proxy()
      .issue_and_set_all_roles(
        issue_cost,
        token_display_name,
        token_ticker,
        EsdtTokenType::SemiFungible,
        0,
      )
      .async_call()
      .with_callback(self.callbacks().initiate_sft_callback(&caller))
      .call_and_exit();
  }

Example TX: https://testnet-explorer.elrond.com/transactions/49fa9e32267448ea0c49bfd8ecf8603ba5207ab9fb3dc697cf5e5f391254fadb

The validation logic that sets the "token name is not human readable" error: https://github.com/ElrondNetwork/elrond-go/blob/d6b1389a59f36095203d7cb583318be6adcfa032/vm/systemSmartContracts/esdt.go#L677

Based on the validation logic, names like "Dummy" are ok. Also, I've tried issuing an SFT with the same token name using the testnet wallet and the TX generated from the testnet wallet succeeds. (TX: https://testnet-explorer.elrond.com/transactions/ebc8a2a87ebd474baf94c8f3a0905e765756c05b733c25d60cfb61616b47dbd1#smart)

What am I missing?


Solution

  • It seems that the problem is the trailing LF (0A in hex) line ending in the token name.

    The line ending is not displayed in the "Smart" version of the input data so it's easy to miss. Removing it solved the problem.

    P.s.: if you're interacting with the smart contract using shell interactions, one way of removing the trailing LF is using | tr -d '\n', e.g.:

        TOKEN_DISPLAY_NAME="someName123"
        TOKEN_DISPLAY_NAME_HEX=$(echo ${TOKEN_DISPLAY_NAME} | tr -d '\n' | xxd -p)