As part of the onboarding process for my project, I create wallets for users.
These wallets are fully onboarded to my game and are prefunded with the games native token. Users literally click 1 button and are fully onboarded.
However, when the Solana network is under load, getOrCreateAssociatedTokenAccount
fails. In fact, getOrCreateAssociatedTokenAccount
fails very often even when solana is not under load.
I believe this is due to getOrCreateAssociatedTokenAccount
not having a priority fee. I cannot attach a priority fee or set the CU's on the function.
This high level function call which is supposed to create or get a users token account is highly unreliable, as it fails any time Solana is under load.
Is it possible for me to create my own Transaction object in which I can attach a priority fee myself so that Solana doesnt drop the transaction?
I use a Helius paid RPC, and whenever I can attach a priority fee to any transaction, those transactions go through almost every time.
https://solana-labs.github.io/solana-program-library/token/js/functions/getOrCreateAssociatedTokenAccount.html
Here is a code snippet of my code
const getConnection = () => {
const endpoint = process.env.NODE_ENV == 'production'
? `https://mainnet.helius-rpc.com/?api-key=${process.env.HELIUS_API_KEY}`
: 'https://api.devnet.solana.com';
let connection = new Connection(endpoint, 'confirmed');
return connection
};
async function getOrCreateRNGTokenAccount(user_pub_key, keyPair, connection) {
try {
logWithFileAndLine('info', `ATTEMPTING TO GET OR CREATE RNG TOKEN ACCOUNT FOR USER`);
const userTokenAccount = await getOrCreateAssociatedTokenAccount(
connection,
keyPair,
RNG_TOKEN_MINT,
user_pub_key
);
return userTokenAccount.address.toString();
} catch (error) {
logWithFileAndLine('error', `Error in getOrCreateAssociatedTokenAccount: ${error.message}`);
return null;
}
}