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 Parameter | Default type |
|---|---|
TX | any |
SignedTX | any |
Signer extends AbstractSigner | AbstractSigner |
ChainId extends string | string |
NativeSigner | any |
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
| Parameter | Type | Description |
|---|---|---|
txData | string | Serialized 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
| Parameter | Type | Description |
|---|---|---|
txData | string | Serialized 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
| Parameter | Type | Description |
|---|---|---|
signer | string | Address to check the balance of |
token | string | Token |
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
| Parameter | Type | Description |
|---|---|---|
txId | string | Transaction 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
| Parameter | Type | Description |
|---|---|---|
tx | string | Serialized 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
| Parameter | Type | Description |
|---|---|---|
address | string | |
lenient? | boolean | Whether 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
| Parameter | Type | Description |
|---|---|---|
tokenIdentifier | string |
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
| Parameter | Type | Description |
|---|---|---|
address | string |
Returns
string
offBeforeTxReplace()
offBeforeTxReplace(callback): boolean;
Defined in: atomiq-base/src/chains/ChainInterface.ts:193
Remove tx replace callback
Parameters
| Parameter | Type | Description |
|---|---|---|
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
| Parameter | Type | Description |
|---|---|---|
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
| Parameter | Type | Description |
|---|---|---|
signer | Signer | Signer to use for signing transactions |
txs | TX[] | Transactions to send |
waitForConfirmation? | boolean | Whether to wait for transaction confirmation (if parallel is not specified, every transaction's confirmation except the last one is awaited) |
abortSignal? | AbortSignal | Abort signal |
parallel? | boolean | Whether 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
| Parameter | Type | Description |
|---|---|---|
signedTxs | SignedTX[] | Signed transactions to be sent |
waitForConfirmation? | boolean | Whether to wait for transaction confirmation (if parallel is not specified, every transaction's confirmation except the last one is awaited) |
abortSignal? | AbortSignal | Abort signal |
parallel? | boolean | Whether 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
| Parameter | Type | Description |
|---|---|---|
signedTX | SignedTX | Transaction 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
| Parameter | Type | Description |
|---|---|---|
tx | TX | Transaction 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
| Parameter | Type | Description |
|---|---|---|
signer | Signer | Signer/owner of the tokens |
token | string | Token to transfer |
amount | bigint | Amount of token to transfer |
dstAddress | string | Destination address of the transfer |
txOptions? | TransactionConfirmationOptions | Transaction 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
| Parameter | Type | Description |
|---|---|---|
signer | string | Signer/owner of the tokens |
token | string | Token to transfer |
amount | bigint | Amount of token to transfer |
dstAddress | string | Destination address of the transfer |
feeRate? | string | Optional 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
| Parameter | Type |
|---|---|
signer | NativeSigner |
Returns
Promise<Signer>