Library
Node.js library for your backend application
You can integrate Octane capabilities to you own backend application. In this case, think of Octane as a transaction validation layer for fee payment: we'll target to implement as much anti-draining checks as possible, as well as helper functions to create accounts, swap the money
Currently the library is extremely early in development and testing. You can't install it through npm for now. If you want to contribute to development, check out the pull request.
Library mode is new and untested. The library isn't distributed with npm. Use at your own risk.
Signs transaction by fee payer if both are true:
a) the first instruction is a transfer of token fee to given account
b) the second instruction creates an associated token account with initialization fees paid by fee payer.
This action allows end users to transfer some tokens to a new associated token account, while paying rent fees in SPL tokens instead of SOL.
Token fee for this operation should be higher then usual. In this operation, node owners pay SOL for both transaction fees and rent exemption of the newly created account.
const { signature } = await createAccountIfTokenFeePaid(
connection,
accountTransaction,
feePayerKeypair,
2,
5000,
[
{
mint: mint,
account: feePayerTokenAccount.address,
decimals: 9,
fee: BigInt(100),
},
],
cache
);
accountTransaction.addSignature(feePayerKeypair.publicKey, base58.decode(signature));
await sendAndConfirmRawTransaction(connection, accountTransaction.serialize(), { commitment: 'confirmed' });
Parameter | Description |
---|---|
connection | Connection to a Solana node |
transaction | Transaction to sign |
feePayer | Keypair for fee payer |
maxSignatures | Maximum allowed signatures in the transaction including fee payer's |
lamportsPerSignature | Maximum transaction fee payment amount in lamports |
allowedTokens | List of tokens that can be used with token fee receiver accounts and fee details |
cache | A cache to store duplicate transactions |
Sign transaction by fee payer if first instruction of transaction is a transfer of token fee.
const { signature } = await signWithTokenFee(
connection,
transaction,
feePayerKeypair,
2,
5000,
[
{
mint: mint,
account: feePayerTokenAccount.address,
decimals: 9,
fee: BigInt(100),
},
],
cache
);
transaction.addSignature(feePayerKeypair.publicKey, base58.decode(signature));
await sendAndConfirmRawTransaction(connection, transaction.serialize(), { commitment: 'confirmed' });
Parameter | Description |
---|---|
connection | Connection to a Solana node |
transaction | Transaction to sign |
feePayer | Keypair for fee payer |
maxSignatures | Maximum allowed signatures in the transaction including fee payer's |
lamportsPerSignature | Maximum transaction fee payment amount in lamports |
allowedTokens | List of tokens that can be used with token fee receiver accounts and fee details |
cache | A cache to store duplicate transactions |
Last modified 1yr ago