1

In my application I use the signatures returned from web3.sendAndConfirmTransaction to do some offline/async reporting relating to the fees incurred by my transactions.

i.e. i use the signature to retrieve the transaction and then use the transaction?.meta?.fee field.

I have noticed though, when my transaction contains 2 instructions (in my example below) that the signature returned only contains the fee relating to 1 of the instructions. When I check the transaction history of my phantom wallet I can clearly see 2 separate fees - one for each instruction

async createTokenMetadataForToken(
    business,
    token_type
  ) {

    const mint_authority = web3.Keypair.fromSeed(
      derivePath(
        `m/44'/501'/0'/0'`,
        Bip39.mnemonicToSeedSync(
          JSON.parse(business.keys).MINTER_SEED
        ).toString("hex")
      ).key
    );

    const metadata = await Metadata.getPDA(token_type.token_address);

    const host = (config.nodeEnv == 'prod') ? 'https://<url>' : 'https://<url>'

    const createMetadataTx = new CreateMetadataV2(
      { feePayer: mint_authority.publicKey },
      {
        metadata,
        metadataData: new DataV2({
          uri: `${host}/token_type/${token_type.token_type_id}/metadata`,
          name: token_type.name,
          symbol: token_type.symbol,
          sellerFeeBasisPoints: 100,
          creators: null,
          collection: null,
          uses: null,
          tokenStandard: TokenStandard.FungibleAsset,
        }),
        updateAuthority: mint_authority.publicKey,
        mint: new web3.PublicKey(token_type.token_address),
        mintAuthority: mint_authority.publicKey,
      }
    );

    const connection = getConnection(token_type.cluster);

    const transaction = new web3.Transaction();

    console.log("creating metadata")
    transaction.add(createMetadataTx)

    
    if(token_type?.equity_total_supply > 0){

      console.log("also creating equity in same trx..")

      //look up token
      const token = new Token(
        connection,
        new web3.PublicKey(token_type.token_address),
        TOKEN_PROGRAM_ID,
        mint_authority
      );

      const recipientTokenAddress = await token.getOrCreateAssociatedAccountInfo(
        new web3.PublicKey(mint_authority.publicKey)
      );

      transaction.add(
        Token.createMintToInstruction(
          TOKEN_PROGRAM_ID,
          new web3.PublicKey(token_type.token_address),
          recipientTokenAddress.address,
          mint_authority.publicKey,
          [mint_authority],
          token_type?.equity_total_supply
        )
      )
      
      
    }

    const sig = await web3.sendAndConfirmTransaction(connection, transaction, [mint_authority], {
      skipPreflight: false
    })
    


    return sig; //This signature only contains fee of one of the parts of the transaction

  }
1977
  • 2,580
  • 6
  • 26
  • 37

0 Answers0