Skip to main content

SolanaChainInterface

Defined in: atomiq-chain-solana/src/solana/chain/SolanaChainInterface.ts:51

Main chain interface for interacting with Solana blockchain

Implements​

Constructors​

Constructor​

new SolanaChainInterface(
connection,
retryPolicy?,
solanaFeeEstimator?): SolanaChainInterface;

Defined in: atomiq-chain-solana/src/solana/chain/SolanaChainInterface.ts:119

Parameters​

ParameterType
connectionConnection
retryPolicy?SolanaRetryPolicy
solanaFeeEstimator?SolanaFees

Returns​

SolanaChainInterface

Properties​

Blocks​

readonly Blocks: SolanaBlocks;

Defined in: atomiq-chain-solana/src/solana/chain/SolanaChainInterface.ts:88

Block-related read module.


chainId​

readonly chainId: "SOLANA" = "SOLANA";

Defined in: atomiq-chain-solana/src/solana/chain/SolanaChainInterface.ts:61

Chain identifier string

Implementation of​

ChainInterface.chainId


Events​

readonly Events: SolanaEvents;

Defined in: atomiq-chain-solana/src/solana/chain/SolanaChainInterface.ts:112

Event/log scanning module.


Fees​

Fees: SolanaFees;

Defined in: atomiq-chain-solana/src/solana/chain/SolanaChainInterface.ts:92

Fee estimation and fee-rate module.


Signatures​

readonly Signatures: SolanaSignatures;

Defined in: atomiq-chain-solana/src/solana/chain/SolanaChainInterface.ts:108

Signature utilities module.


Slots​

readonly Slots: SolanaSlots;

Defined in: atomiq-chain-solana/src/solana/chain/SolanaChainInterface.ts:96

Slot-related read module.


Tokens​

readonly Tokens: SolanaTokens;

Defined in: atomiq-chain-solana/src/solana/chain/SolanaChainInterface.ts:100

Token operations module.


Transactions​

readonly Transactions: SolanaTransactions;

Defined in: atomiq-chain-solana/src/solana/chain/SolanaChainInterface.ts:104

Transaction send/confirm/serialization module.

Methods​

deserializeSignedTx()​

deserializeSignedTx(txData): Promise<Transaction>;

Defined in: atomiq-chain-solana/src/solana/chain/SolanaChainInterface.ts:258

Deserializes a transaction from string

Parameters​

ParameterTypeDescription
txDatastringSerialized transaction data string

Returns​

Promise<Transaction>

Implementation of​

ChainInterface.deserializeSignedTx


deserializeTx()​

deserializeTx(txData): Promise<SolanaTx>;

Defined in: atomiq-chain-solana/src/solana/chain/SolanaChainInterface.ts:244

Deserializes a transaction from string

Parameters​

ParameterTypeDescription
txDatastringSerialized transaction data string

Returns​

Promise<SolanaTx>

Implementation of​

ChainInterface.deserializeTx


getBalance()​

getBalance(signer, tokenAddress): Promise<bigint>;

Defined in: atomiq-chain-solana/src/solana/chain/SolanaChainInterface.ts:139

Returns the token balance of a specific address

Parameters​

ParameterTypeDescription
signerstringAddress to check the balance of
tokenAddressstringToken

Returns​

Promise<bigint>

Implementation of​

ChainInterface.getBalance


getFinalizedBlock()​

getFinalizedBlock(): Promise<{
blockHash: string;
height: number;
}>;

Defined in: atomiq-chain-solana/src/solana/chain/SolanaChainInterface.ts:279

Returns the latest known finalized block data (this is a block with 100% certainty of not getting re-org, i.e. a block already committed on L1)

Returns​

Promise<{ blockHash: string; height: number; }>

Implementation of​

ChainInterface.getFinalizedBlock


getNativeCurrencyAddress()​

getNativeCurrencyAddress(): string;

Defined in: atomiq-chain-solana/src/solana/chain/SolanaChainInterface.ts:170

Returns the token address of the native currency of the chain

Returns​

string

Implementation of​

ChainInterface.getNativeCurrencyAddress


getTxIdStatus()​

getTxIdStatus(txId): Promise<"not_found" | "pending" | "success" | "reverted">;

Defined in: atomiq-chain-solana/src/solana/chain/SolanaChainInterface.ts:265

Returns the status of the given transactionId (use getTxStatus whenever possible, it's more reliable)

Parameters​

ParameterTypeDescription
txIdstringTransaction ID

Returns​

Promise<"not_found" | "pending" | "success" | "reverted">

Implementation of​

ChainInterface.getTxIdStatus


getTxStatus()​

getTxStatus(tx): Promise<"not_found" | "pending" | "success" | "reverted">;

Defined in: atomiq-chain-solana/src/solana/chain/SolanaChainInterface.ts:272

Returns the status of the given serialized transaction

Parameters​

ParameterTypeDescription
txstringSerialized transaction

Returns​

Promise<"not_found" | "pending" | "success" | "reverted">

Implementation of​

ChainInterface.getTxStatus


isValidAddress()​

isValidAddress(address): boolean;

Defined in: atomiq-chain-solana/src/solana/chain/SolanaChainInterface.ts:156

Checks if a given string is a valid wallet address

Parameters​

ParameterTypeDescription
addressstring

Returns​

boolean

Implementation of​

ChainInterface.isValidAddress


isValidToken()​

isValidToken(tokenIdentifier): boolean;

Defined in: atomiq-chain-solana/src/solana/chain/SolanaChainInterface.ts:337

Checks if a given string is a valid token identifier

Parameters​

ParameterTypeDescription
tokenIdentifierstring

Returns​

boolean

Implementation of​

ChainInterface.isValidToken


normalizeAddress()​

normalizeAddress(address): string;

Defined in: atomiq-chain-solana/src/solana/chain/SolanaChainInterface.ts:163

Normalizes a given address i.e. pads it to the specific size

Parameters​

ParameterTypeDescription
addressstring

Returns​

string

Implementation of​

ChainInterface.normalizeAddress


offBeforeTxReplace()​

offBeforeTxReplace(callback): boolean;

Defined in: atomiq-chain-solana/src/solana/chain/SolanaChainInterface.ts:293

Remove tx replace callback

Parameters​

ParameterTypeDescription
callback(oldTx, oldTxId, newTx, newTxId) => Promise<void>

Returns​

boolean

Implementation of​

ChainInterface.offBeforeTxReplace


offBeforeTxSigned()​

offBeforeTxSigned(callback): boolean;

Defined in: atomiq-chain-solana/src/solana/chain/SolanaChainInterface.ts:312

Parameters​

ParameterType
callback(tx) => Promise<void>

Returns​

boolean

Inherit Doc​


offSendTransaction()​

offSendTransaction(callback): boolean;

Defined in: atomiq-chain-solana/src/solana/chain/SolanaChainInterface.ts:330

Unregisters a previously registered transaction sender override hook.

Parameters​

ParameterTypeDescription
callback(tx, options?) => Promise<string>Previously registered callback

Returns​

boolean


onBeforeTxReplace()​

onBeforeTxReplace(callback): void;

Defined in: atomiq-chain-solana/src/solana/chain/SolanaChainInterface.ts:300

Callback called when transaction is being replaced (used for EVM, when fee is bumped on an unconfirmed tx)

Parameters​

ParameterTypeDescription
callback(oldTx, oldTxId, newTx, newTxId) => Promise<void>

Returns​

void

Implementation of​

ChainInterface.onBeforeTxReplace


onBeforeTxSigned()​

onBeforeTxSigned(callback): void;

Defined in: atomiq-chain-solana/src/solana/chain/SolanaChainInterface.ts:305

Parameters​

ParameterType
callback(tx) => Promise<void>

Returns​

void

Inherit Doc​


onSendTransaction()​

onSendTransaction(callback): void;

Defined in: atomiq-chain-solana/src/solana/chain/SolanaChainInterface.ts:321

Registers a low-level transaction sender override hook.

Parameters​

ParameterTypeDescription
callback(tx, options?) => Promise<string>Callback used for raw transaction publishing

Returns​

void


prepareTxs()​

prepareTxs(txs): Promise<SolanaTx[]>;

Defined in: atomiq-chain-solana/src/solana/chain/SolanaChainInterface.ts:229

Prepares transaction for signing, by assigning a nonce, or a last valid blockhash

Parameters​

ParameterTypeDescription
txsSolanaTx[]Transactions to prepare

Returns​

Promise<SolanaTx[]>

Remarks​

Ensure that all transactions are using the same signer, else this function might throw!

Implementation of​

ChainInterface.prepareTxs


randomAddress()​

randomAddress(): string;

Defined in: atomiq-chain-solana/src/solana/chain/SolanaChainInterface.ts:349

Returns a random valid wallet address

Returns​

string

Implementation of​

ChainInterface.randomAddress


randomSigner()​

randomSigner(): SolanaSigner;

Defined in: atomiq-chain-solana/src/solana/chain/SolanaChainInterface.ts:356

Returns randomly generated signer

Returns​

SolanaSigner

Implementation of​

ChainInterface.randomSigner


sendAndConfirm()​

sendAndConfirm(
signer,
txs,
waitForConfirmation?,
abortSignal?,
parallel?,
onBeforePublish?): Promise<string[]>;

Defined in: atomiq-chain-solana/src/solana/chain/SolanaChainInterface.ts:202

Signs, sends a batch of transaction and optionally waits for their confirmation

Parameters​

ParameterTypeDescription
signerSolanaSignerSigner to use for signing transactions
txsSolanaTx[]Transactions to send
waitForConfirmation?booleanWhether to wait for transaction confirmation (if parallel is not specified, every transaction's confirmation except the last one is awaited)
abortSignal?AbortSignalAbort signal
parallel?booleanWhether to send all transactions in parallel or one by one (always waiting for the previous TX to confirm)
onBeforePublish?(txId, rawTx) => Promise<void>Callback called before a tx is broadcast

Returns​

Promise<string[]>

Implementation of​

ChainInterface.sendAndConfirm


sendSignedAndConfirm()​

sendSignedAndConfirm(
txs,
waitForConfirmation?,
abortSignal?,
parallel?,
onBeforePublish?): Promise<string[]>;

Defined in: atomiq-chain-solana/src/solana/chain/SolanaChainInterface.ts:216

Sends already signed transactions and optionally waits for their confirmation

Parameters​

ParameterTypeDescription
txsTransaction[]Signed transactions to be sent
waitForConfirmation?booleanWhether to wait for transaction confirmation (if parallel is not specified, every transaction's confirmation except the last one is awaited)
abortSignal?AbortSignalAbort signal
parallel?booleanWhether to send all transactions in parallel or one by one (always waiting for the previous TX to confirm)
onBeforePublish?(txId, rawTx) => Promise<void>Callback called before a tx is broadcast

Returns​

Promise<string[]>

Implementation of​

ChainInterface.sendSignedAndConfirm


serializeSignedTx()​

serializeSignedTx(tx): Promise<string>;

Defined in: atomiq-chain-solana/src/solana/chain/SolanaChainInterface.ts:251

Serializes a given transaction to a string

Parameters​

ParameterTypeDescription
txTransactionTransaction to serialize

Returns​

Promise<string>

Implementation of​

ChainInterface.serializeSignedTx


serializeTx()​

serializeTx(tx): Promise<string>;

Defined in: atomiq-chain-solana/src/solana/chain/SolanaChainInterface.ts:237

Serializes a given transaction to a string

Parameters​

ParameterTypeDescription
txSolanaTxTransaction to serialize

Returns​

Promise<string>

Implementation of​

ChainInterface.serializeTx


transfer()​

transfer(
signer,
token,
amount,
dstAddress,
txOptions?): Promise<string>;

Defined in: atomiq-chain-solana/src/solana/chain/SolanaChainInterface.ts:184

Transfers the specific token to a given recipient

Parameters​

ParameterTypeDescription
signerSolanaSignerSigner/owner of the tokens
tokenstringToken to transfer
amountbigintAmount of token to transfer
dstAddressstringDestination address of the transfer
txOptions?TransactionConfirmationOptionsTransaction options

Returns​

Promise<string>

Implementation of​

ChainInterface.transfer


txsTransfer()​

txsTransfer(
signer,
token,
amount,
dstAddress,
feeRate?): Promise<SolanaTx[]>;

Defined in: atomiq-chain-solana/src/solana/chain/SolanaChainInterface.ts:177

Returns transactions for transferring a specific token to a given recipient

Parameters​

ParameterTypeDescription
signerstringSigner/owner of the tokens
tokenstringToken to transfer
amountbigintAmount of token to transfer
dstAddressstringDestination address of the transfer
feeRate?stringOptional fee rate to use for the transaction (fetched on-demand if not provided)

Returns​

Promise<SolanaTx[]>

Implementation of​

ChainInterface.txsTransfer


verifyNetwork()​

verifyNetwork(bitcoinNetwork): Promise<void>;

Defined in: atomiq-chain-solana/src/solana/chain/SolanaChainInterface.ts:369

Verifies whether the set network of this chain interface matches the passed bitcoin network (i.e. mainnet should use mainnet networks and testnets should use testnet networks)

Parameters​

ParameterType
bitcoinNetworkBitcoinNetwork

Returns​

Promise<void>

Throws​

When the underlying network doesn't match

Implementation of​

ChainInterface.verifyNetwork


wrapSigner()​

wrapSigner(signer): Promise<SolanaSigner>;

Defined in: atomiq-chain-solana/src/solana/chain/SolanaChainInterface.ts:365

Wraps a native chain signer object to an atomiq-understandable AbstractSigner

Parameters​

ParameterType
signerWallet

Returns​

Promise<SolanaSigner>

Implementation of​

ChainInterface.wrapSigner