Solana: Bigint Error during NFT transmission **
As a Solana developper, you probally encountered the problems wth NFT transmission (non-digil tokens) use the SPL-Cater program. In this article, we will be examine the cause and solution of a common problem, that can be during NFT transfers: Bigint errors.
problem:
Whentsferring NFT from the account to ther, the transmission can you discard by the error du mismal ) between the two accounts. This can happen wen the "Transfer" function to transfer
Error:
Here is an example of the how ti error May lock in your code:
Javascript
Const {Connction, Publickey, Transaction, Keypair} = Require (‘@solana/Web3.js’);
// Create a new pair of Keys for the sender
Const SenderKeyyPair = Keypair.Generate ();
// Define the connction and Key of the SPL-Coken program
Const Connection = New Connction (‘
Const Spotkenprogramde = ‘Your_spl_oken_program_id’;
Const repocntid = ‘your_spl_ocen_accoun_id’;
// Create a transaction to transmit NFT
Const transaction = new transaction ()
.add (
[
// Set the transmission parameters
{
Account0: SPLTOENCCOUNTID,
Amount: Bigint (1),
PUBKEY: Spltokenprogramide.Topublickey (),
PUBKEY: SenderKeyPair.publickey.Tobase58 (),
},
]
);
// try to transfer NFT without error
Transaction.Sign (SederKyPair);
Connction.sendtransaction;
// If this line causes an error, it mes that theeee is mysmatch without the bigg
`
Solution:
To correct the Bigint error, you must to make, that both accounts has a sulficient balance and the “mount” parameter is valid. Here are a feat steps to solve the Problem:
- Check your account balances: Make of the both accounts havh of monances (BNA) for the amount of the transfer.
- Oblide the parameter
Sum:
Verify that value of the 'sum' is valid Bigint and not exceed thees the maximum alllowed value (eg 2^256-1).
- Update the transaction parameters: Change thesum to a valid Biginth or, if necessary, update it to a
Gere is an updated example that concerns the following problems:
`Javascript
Const {Connction, Publickey, Transaction, Keypair} = Require (‘@solana/Web3.js’);
// Create a new pair of Keys for the sender
Const SenderKeyPair = Keypair.Generate ();
// Define the connction and Key of the SPL-Coken program
Const Connection = New Connction (‘
Const Spotkenprogramde = ‘Your_spl_oken_program_id’;
Const repocntid = ‘your_spl_ocen_accoun_id’;
// Calculate the required amount in bigs
Const I require = 1n;
Let the Balance of SPLTOCENACUNTID.BALCE.GET (SpltenacCoountid.publickey) .amount;
// Check that is the monance to be transferred
if (availability
Throw out a new error (“insufficient bales”);
}
// Create a transaction with updated parameters
Const transaction = new transaction ()
.add (
[
// Set the transmission parameters
{
Account0: SPLTOENCCOUNTID,
Sum: Bigint (obligatory),
PUBKEY: Spltokenprogramide.Topublickey (),
PUBKEY: SenderKeyPair.publickey.Tobase58 (),
},
]
);
// try to transfer NFT without error
Transaction.Sign (SederKyPair);
Connction.sendtransaction;
// If this line doesn’
`
According to thee steps and accordingly, you chauld to a low the Bigint error during NFT transmit.