Alkanes RPC
Overview
The Alkanes RPC interface provides methods for interacting with the Alkanes protocol on Bitcoin. It enables querying balances, simulating transactions, and managing protorunes/alkanes assets.
Base URL
All RPC methods are available via HTTP POST requests to your Alkanes node endpoint.
Common Parameters
blockTag
: Optional parameter for historical queries- Type: string
- Default: "latest"
- Specifies which block state to query
Methods
protorunesbyaddress
Query protorunes balances for a specific address.
async protorunesbyaddress({
address: string,
protocolTag: bigint
}, blockTag?: string): Promise<{
outpoints: OutPoint[],
balanceSheet: RuneOutput[]
}>
Parameters:
address
: Bitcoin address to queryprotocolTag
: Protocol identifier (1n for Alkanes)
Returns:
outpoints
: Array of UTXOs containing protorunesbalanceSheet
: Array of protorune balances
protorunesbyheight
Query protorunes state at a specific block height.
async protorunesbyheight({
height: number,
protocolTag: bigint
}, blockTag?: string): Promise<RunesResponse>
Parameters:
height
: Block height to queryprotocolTag
: Protocol identifier
protorunesbyoutpoint
Query protorunes at a specific UTXO.
async protorunesbyoutpoint({
txid: string,
vout: number,
protocolTag: bigint
}, blockTag?: string): Promise<OutpointResponse>
Parameters:
txid
: Transaction IDvout
: Output indexprotocolTag
: Protocol identifier
simulate
Simulate execution of an Alkanes transaction.
async simulate({
alkanes: AlkaneTransfer[],
transaction: string,
height: bigint,
block: string,
txindex: number,
target: {
block: bigint,
tx: bigint
},
inputs: bigint[],
vout: number,
pointer: number,
refundPointer: number
}, blockTag?: string): Promise<SimulateResponse>
Parameters:
alkanes
: Array of Alkane transferstransaction
: Raw transaction hexheight
: Block heightblock
: Block hashtxindex
: Transaction indextarget
: Alkane contract targetinputs
: Array of operation inputsvout
: Output indexpointer
: Success pointerrefundPointer
: Refund pointer
Error Handling
All methods may throw errors with the following structure:
interface RPCError {
code: number;
message: string;
data?: any;
}
Usage Example
const alkanes = new AlkanesRpc('http://your-node-url');
// Query protorunes balance
const balance = await alkanes.protorunesbyaddress({
address: 'bc1...',
protocolTag: 1n,
});
// Simulate transaction
const simulation = await alkanes.simulate({
alkanes: [],
transaction: '',
height: 1000000n,
txindex: 0,
target: {
block: 2n,
tx: 0n,
},
inputs: [101n],
pointer: 0,
refundPointer: 0,
vout: 0,
});