Typescript integration code : FuelError: Only one field must be provided

  1. Typescript integration Code :
     let contractId = '0x7d2d67a0a91ed9fcd48a2cce15466e39ca213bbbf419e77ea10af2d73ff22579'
  // Create a provider, with the Latest Testnet URL.
  const provider = await Provider.create('https://testnet.fuel.network/v1/graphql');
  const contract = new Contract(contractId, abi, provider);
  const { value } = await contract.functions.total_assets().get();
  console.log("value of Total assets",Number(value))
  const amount = BigInt(1e7);
  const subId = '0x2000000000000000000000000000000000000000000000000000000000000000';
  const recipient = '0xdfa99328085d21926deac89364045a6ebc84da04a051b7c70e2c368eee494b3b'
  const result = await contract.functions.mint(recipient,subId,amount).txParams({gasPrice:1}).call();

Correct me if i am wrong while calling the mint function is correct or not .
getting this error
_FuelError: Only one field must be provided.

mint function I have written in the contract

#[storage(read, write)]
    fn mint(recipient: Identity, sub_id: SubId, amount: u64) {
            require(sub_id == +, "Incorrect Sub Id");
        // Initialize total supply if not already initialized
        if !storage.is_initialized.read() {

        // Increment total supply of the asset and mint to the recipient.
            .write(amount + storage.total_supply.read());
        mint_to(recipient, DEFAULT_SUB_ID, amount);

Can you share the output for the command fuelup show from your terminal? and also what TS sdk version are you using?

Hi @Nazeeh21

fuelup show


Fuelsdk version will 0.90.0

please Guide me to assets Mint in my NFT Contract

Hi @mahesh_d_luffy, I can see you are passing the Identity parameter incorrectly. It is expecting an enum value and you have just passed the raw b256 address. It can be passed like this. This forum post is actually very similar to your issue.

I’d also reccomend using typegen via the Fuels CLI to create the function inputs to ensure you are passing them correctly.

But I’d expect you to pass the first parameter like so:

const address = { bits: '0xdfa99328085d21926deac89364045a6ebc84da04a051b7c70e2c368eee494b3b' };
const identity = { Address: address };
const result = await contract.functions.mint(identity,subId,amount).txParams({gasPrice:1}).call();

1 Like

yes I have tried , but I’m getting this

Screenshot 2024-07-05 at 6.40.35 PM

Sorry you’re still having trouble @mahesh_d_luffy. Just to check we’re on the same page, I added a testcase example to the TS SDK that includes the mint function from the NFT-Contract. I’ve used Typegen to help build the function inputs.

But you can check out the example here.