Skip to main content

ChainInterface<TX, SignedTX, Signer, ChainId, NativeSigner>

Defined in: atomiq-base/src/chains/ChainInterface.ts:38

An interface representing a smart chain, allowing basic operations on the chain and reading chain data

Type Parameters

Type ParameterDefault type
TXany
SignedTXany
Signer extends AbstractSignerAbstractSigner
ChainId extends stringstring
NativeSignerany

Properties

chainId

readonly chainId: ChainId;

Defined in: atomiq-base/src/chains/ChainInterface.ts:49

Chain identifier string

Methods

deserializeSignedTx()

deserializeSignedTx(txData): Promise<SignedTX>;

Defined in: atomiq-base/src/chains/ChainInterface.ts:134

Deserializes a transaction from string

Parameters

ParameterTypeDescription
txDatastringSerialized transaction data string

Returns

Promise<SignedTX>


deserializeTx()

deserializeTx(txData): Promise<TX>;

Defined in: atomiq-base/src/chains/ChainInterface.ts:120

Deserializes a transaction from string

Parameters

ParameterTypeDescription
txDatastringSerialized transaction data string

Returns

Promise<TX>


getBalance()

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

Defined in: atomiq-base/src/chains/ChainInterface.ts:57

Returns the token balance of a specific address

Parameters

ParameterTypeDescription
signerstringAddress to check the balance of
tokenstringToken

Returns

Promise<bigint>


getFinalizedBlock()

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

Defined in: atomiq-base/src/chains/ChainInterface.ts:154

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; }>


getNativeCurrencyAddress()

getNativeCurrencyAddress(): string;

Defined in: atomiq-base/src/chains/ChainInterface.ts:62

Returns the token address of the native currency of the chain

Returns

string


getTxIdStatus()

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

Defined in: atomiq-base/src/chains/ChainInterface.ts:148

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">


getTxStatus()

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

Defined in: atomiq-base/src/chains/ChainInterface.ts:141

Returns the status of the given serialized transaction

Parameters

ParameterTypeDescription
txstringSerialized transaction

Returns

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


isValidAddress()

isValidAddress(address, lenient?): boolean;

Defined in: atomiq-base/src/chains/ChainInterface.ts:70

Checks if a given string is a valid wallet address

Parameters

ParameterTypeDescription
addressstring
lenient?booleanWhether a lenient parsing should be used (i.e. don't strictly enforce the Starknet address lengths)

Returns

boolean


isValidToken()

isValidToken(tokenIdentifier): boolean;

Defined in: atomiq-base/src/chains/ChainInterface.ts:84

Checks if a given string is a valid token identifier

Parameters

ParameterTypeDescription
tokenIdentifierstring

Returns

boolean


normalizeAddress()

normalizeAddress(address): string;

Defined in: atomiq-base/src/chains/ChainInterface.ts:77

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

Parameters

ParameterTypeDescription
addressstring

Returns

string


offBeforeTxReplace()

offBeforeTxReplace(callback): boolean;

Defined in: atomiq-base/src/chains/ChainInterface.ts:193

Remove tx replace callback

Parameters

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

Returns

boolean


onBeforeTxReplace()

onBeforeTxReplace(callback): void;

Defined in: atomiq-base/src/chains/ChainInterface.ts:186

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


randomAddress()

randomAddress(): string;

Defined in: atomiq-base/src/chains/ChainInterface.ts:198

Returns a random valid wallet address

Returns

string


randomSigner()

randomSigner(): Signer;

Defined in: atomiq-base/src/chains/ChainInterface.ts:203

Returns randomly generated signer

Returns

Signer


sendAndConfirm()

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

Defined in: atomiq-base/src/chains/ChainInterface.ts:167

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

Parameters

ParameterTypeDescription
signerSignerSigner to use for signing transactions
txsTX[]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[]>


sendSignedAndConfirm()

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

Defined in: atomiq-base/src/chains/ChainInterface.ts:179

Sends already signed transactions and optionally waits for their confirmation

Parameters

ParameterTypeDescription
signedTxsSignedTX[]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[]>


serializeSignedTx()

serializeSignedTx(signedTX): Promise<string>;

Defined in: atomiq-base/src/chains/ChainInterface.ts:127

Serializes a given transaction to a string

Parameters

ParameterTypeDescription
signedTXSignedTXTransaction to serialize

Returns

Promise<string>


serializeTx()

serializeTx(tx): Promise<string>;

Defined in: atomiq-base/src/chains/ChainInterface.ts:113

Serializes a given transaction to a string

Parameters

ParameterTypeDescription
txTXTransaction to serialize

Returns

Promise<string>


transfer()

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

Defined in: atomiq-base/src/chains/ChainInterface.ts:95

Transfers the specific token to a given recipient

Parameters

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

Returns

Promise<string>


txsTransfer()

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

Defined in: atomiq-base/src/chains/ChainInterface.ts:106

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<TX[]>


wrapSigner()

wrapSigner(signer): Promise<Signer>;

Defined in: atomiq-base/src/chains/ChainInterface.ts:208

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

Parameters

ParameterType
signerNativeSigner

Returns

Promise<Signer>