ESDT token name not properly set during Elrond Rust testing

I’m working with elrond-wasm version 0.32.0 and running into problems when testing my smart contract. When I try to set the name for an ESDT token, the system keeps returning the token identifier instead of the actual name I specified.

What I’m doing

First, I configure the NFT properties using this approach:

blockchain_wrapper.set_nft_balance_all_properties::<Empty>(
    &contract_wrapper.address_ref(),
    &WEAPON_TOKEN_ID,
    WEAPON_TOKEN_NONCE,
    &rust_biguint!(5u64),
    &Empty,
    0,
    Option::Some(&user_address),
    Option::Some(WEAPON_TOKEN_NAME),
    Option::Some(b""),
    &[],
);

Then I try to retrieve the token name:

blockchain_wrapper
    .execute_query(&contract_wrapper, |sc| {
        let token_data = sc.blockchain().get_esdt_token_data(
            &ManagedAddress::from_address(&contract_wrapper.address_ref()),
            &TokenIdentifier::from_esdt_bytes(WEAPON_TOKEN_ID),
            WEAPON_TOKEN_NONCE,
        );

        // token_data.name returns WEAPON_TOKEN_ID instead of WEAPON_TOKEN_NAME
        assert_eq!(token_data.name, ManagedBuffer::new_from_bytes(WEAPON_TOKEN_NAME));
    })
    .assert_ok();

The assertion fails because token_data.name contains the token ID rather than the name I set. Is this expected behavior or am I missing something in my test setup?

Full test example

#[test]
fn token_name_assignment_test() {
    const WASM_FILE: &'static str = "sc-weapon-nft/output/weapon_nft.wasm";

    const WEAPON_TOKEN_ID: &[u8] = b"WEAPON-b2b2b2";
    const WEAPON_TOKEN_NAME: &[u8] = b"magic sword";
    const WEAPON_TOKEN_NONCE: u64 = 1;

    let zero_amount = rust_biguint!(0u64);
    let mut blockchain_wrapper = BlockchainStateWrapper::new();
    let user_address = blockchain_wrapper.create_user_account(&zero_amount);
    let contract_wrapper = blockchain_wrapper.create_sc_account(
        &zero_amount,
        Some(&user_address),
        weapon_nft::contract_obj,
        WASM_FILE,
    );

    // initialize contract
    blockchain_wrapper
        .execute_tx(&user_address, &contract_wrapper, &zero_amount, |sc| {
            let init_result = sc.init(managed_token_id!(MAIN_TOKEN_ID));
            assert_eq!(init_result, SCResult::Ok(()));
        })
        .assert_ok();
    blockchain_wrapper.add_mandos_set_account(contract_wrapper.address_ref());

    blockchain_wrapper.set_nft_balance_all_properties::<Empty>(
        &contract_wrapper.address_ref(),
        &WEAPON_TOKEN_ID,
        WEAPON_TOKEN_NONCE,
        &rust_biguint!(5u64),
        &Empty,
        0,
        Option::Some(&user_address),
        Option::Some(WEAPON_TOKEN_NAME),
        Option::Some(b""),
        &[],
    );

    blockchain_wrapper
        .execute_query(&contract_wrapper, |sc| {
            let token_data = sc.blockchain().get_esdt_token_data(
                &ManagedAddress::from_address(&contract_wrapper.address_ref()),
                &TokenIdentifier::from_esdt_bytes(WEAPON_TOKEN_ID),
                WEAPON_TOKEN_NONCE,
            );

            println!("Retrieved name: {:?}", token_data.name);
            assert_eq!(token_data.name, ManagedBuffer::new_from_bytes(WEAPON_TOKEN_NAME));
        })
        .assert_ok();
}

This is really interesting! I’ve been working with elrond-wasm testing lately too and I’m curious - are you sure set_nft_balance_all_properties isn’t setting the name properly?

Try debugging by checking what actually gets stored. Have you printed out what blockchain_wrapper thinks it stored right after calling set_nft_balance_all_properties?

Also, does this happen with fungible ESDT tokens instead of NFTs? That’d help figure out if it’s NFT-specific or a broader issue with how the test framework handles token metadata.

One more thing - are you using custom token creation logic in your contract that might override the name? If your contract calls nft_create or similar methods internally, that could mess with what the test framework is trying to set up.

What version of the blockchain simulator are you running with the 0.32.0 wasm framework? Version mismatches sometimes cause weird behaviors like this.

Same issue with 0.32.0 - the test framework just ignores NFT names :sweat_smile: Use set_esdt_balance to set up tokens, then manually set the attributes. Also double-check your contract’s calling the right blockchain methods!

I hit this same issue in 0.32.0 - it’s actually working as intended in the test framework. The set_nft_balance_all_properties method does store the name internally, but get_esdt_token_data falls back to returning the token identifier when the name field is empty or null. The problem is the test framework doesn’t fully simulate how the blockchain stores token metadata. In production, ESDT token names are handled by the protocol itself, but the testing environment works differently. Try accessing the token name directly through the blockchain wrapper’s internal storage instead of using get_esdt_token_data. You can verify this by checking if the same code works when deployed to devnet - it should pull the proper name there. If you need to test name retrieval specifically, just mock the get_esdt_token_data response in your test setup rather than relying on the framework’s implementation.