Gateways
getGateway()
Retrieves a gateway's info by its staking wallet address.
const ario = ARIO.mainnet();
const gateway = await ario.getGateway({
address: '-7vXsQZQDk8TMDlpiSLy3CnLi5PDPlAaN2DaynORpck',
});
Output:
{
"observerAddress": "IPdwa3Mb_9pDD8c2IaJx6aad51Ss-_TfStVwBuhtXMs",
"operatorStake": 250000000000,
"settings": {
"fqdn": "ar-io.dev",
"label": "AR.IO Test",
"note": "Test Gateway operated by PDS for the AR.IO ecosystem.",
"port": 443,
"properties": "raJgvbFU-YAnku-WsupIdbTsqqGLQiYpGzoqk9SCVgY",
"protocol": "https"
},
"startTimestamp": 1720720620813,
"stats": {
"failedConsecutiveEpochs": 0,
"passedEpochCount": 30,
"submittedEpochCount": 30,
"totalEpochCount": 31,
"totalEpochsPrescribedCount": 31
},
"status": "joined",
"vaults": {},
"weights": {
"compositeWeight": 0.97688888893556,
"gatewayPerformanceRatio": 1,
"tenureWeight": 0.19444444444444,
"observerRewardRatioWeight": 1,
"normalizedCompositeWeight": 0.19247316211083,
"stakeWeight": 5.02400000024
}
}
getGateways()
Retrieves registered gateways of the ARIO process, using pagination and sorting by the specified criteria. The cursor
used for pagination is the last gateway address from the previous request.
const ario = ARIO.mainnet();
const gateways = await ario.getGateways({
limit: 100,
sortOrder: 'desc',
sortBy: 'operatorStake',
});
Available sortBy
options are any of the keys on the gateway object, e.g. operatorStake
, start
, status
, settings.fqdn
, settings.label
, settings.note
, settings.port
, settings.protocol
, stats.failedConsecutiveEpochs
, stats.passedConsecutiveEpochs
, etc.
Output:
{
"items": [
{
"gatewayAddress": "QGWqtJdLLgm2ehFWiiPzMaoFLD50CnGuzZIPEdoDRGQ",
"observerAddress": "IPdwa3Mb_9pDD8c2IaJx6aad51Ss-_TfStVwBuhtXMs",
"operatorStake": 250000000000,
"settings": {
"fqdn": "ar-io.dev",
"label": "AR.IO Test",
"note": "Test Gateway operated by PDS for the AR.IO ecosystem.",
"port": 443,
"properties": "raJgvbFU-YAnku-WsupIdbTsqqGLQiYpGzoqk9SCVgY",
"protocol": "https"
},
"startTimestamp": 1720720620813,
"stats": {
"failedConsecutiveEpochs": 0,
"passedEpochCount": 30,
"submittedEpochCount": 30,
"totalEpochCount": 31,
"totalEpochsPrescribedCount": 31
},
"status": "joined",
"vaults": {},
"weights": {
"compositeWeight": 0.97688888893556,
"gatewayPerformanceRatio": 1,
"tenureWeight": 0.19444444444444,
"observerRewardRatioWeight": 1,
"normalizedCompositeWeight": 0.19247316211083,
"stakeWeight": 5.02400000024
}
}
],
"hasMore": true,
"nextCursor": "-4xgjroXENKYhTWqrBo57HQwvDL51mMdfsdsxJy6Y2Z_sA",
"totalItems": 316,
"sortBy": "operatorStake",
"sortOrder": "desc"
}
getGatewayDelegates()
Retrieves all delegates for a specific gateway, paginated and sorted by the specified criteria. The cursor
used for pagination is the last delegate address from the previous request.
const ario = ARIO.mainnet();
const delegates = await ario.getGatewayDelegates({
address: 'QGWqtJdLLgm2ehFWiiPzMaoFLD50CnGuzZIPEdoDRGQ',
limit: 3,
sortBy: 'startTimestamp',
sortOrder: 'desc',
});
Output:
{
"nextCursor": "ScEtph9-vfY7lgqlUWwUwOmm99ySeZGQhOX0MFAyFEs",
"limit": 3,
"sortBy": "startTimestamp",
"totalItems": 32,
"sortOrder": "desc",
"hasMore": true,
"items": [
{
"delegatedStake": 600000000,
"address": "qD5VLaMYyIHlT6vH59TgYIs6g3EFlVjlPqljo6kqVxk",
"startTimestamp": 1732716956301
},
{
"delegatedStake": 508999038,
"address": "KG8TlcWk-8pvroCjiLD2J5zkG9rqC6yYaBuZNqHEyY4",
"startTimestamp": 1731828123742
},
{
"delegatedStake": 510926479,
"address": "ScEtph9-vfY7lgqlUWwUwOmm99ySeZGQhOX0MFAyFEs",
"startTimestamp": 1731689356040
}
]
}
joinNetwork()
Joins a gateway to the ar.io network via its associated wallet.
Note: Requires signer
to be provided on ARIO.init
to sign the transaction.
const ario = ARIO.mainnet({ signer: new ArweaveSigner(jwk) });
const { id: txId } = await ario.joinNetwork(
{
qty: new ARIOToken(10_000).toMARIO(), // minimum operator stake allowed
autoStake: true, // auto-stake operator rewards to the gateway
allowDelegatedStaking: true, // allows delegated staking
minDelegatedStake: new ARIOToken(100).toMARIO(), // minimum delegated stake allowed
delegateRewardShareRatio: 10, // percentage of rewards to share with delegates (e.g. 10%)
label: 'john smith', // min 1, max 64 characters
note: 'The example gateway', // max 256 characters
properties: 'FH1aVetOoulPGqgYukj0VE0wIhDy90WiQoV3U2PeY44', // Arweave transaction ID containing additional properties of the Gateway
observerWallet: '0VE0wIhDy90WiQoV3U2PeY44FH1aVetOoulPGqgYukj', // wallet address of the observer, must match OBSERVER_WALLET on the observer
fqdn: 'example.com', // fully qualified domain name - note: you must own the domain and set the OBSERVER_WALLET on your gateway to match `observerWallet`
port: 443, // port number
protocol: 'https', // only 'https' is supported
},
// optional additional tags
{ tags: [{ name: 'App-Name', value: 'My-Awesome-App' }] },
);
leaveNetwork()
Sets the gateway as leaving
on the ar.io network. Requires signer
to be provided on ARIO.init
to sign the transaction. The gateways operator and delegate stakes are vaulted and will be returned after leave periods. The gateway will be removed from the network after the leave period.
Note: Requires signer
to be provided on ARIO.init
to sign the transaction.
const ario = ARIO.mainnet({ signer: new ArweaveSigner(jwk) });
const { id: txId } = await ario.leaveNetwork(
// optional additional tags
{ tags: [{ name: 'App-Name', value: 'My-Awesome-App' }] },
);
updateGatewaySettings()
Writes new gateway settings to the callers gateway configuration.
Note: Requires signer
to be provided on ARIO.init
to sign the transaction.
const ario = ARIO.mainnet({ signer: new ArweaveSigner(jwk) });
const { id: txId } = await ario.updateGatewaySettings(
{
// any other settings you want to update
minDelegatedStake: new ARIOToken(100).toMARIO(),
},
// optional additional tags
{ tags: [{ name: 'App-Name', value: 'My-Awesome-App' }] },
);
increaseDelegateStake()
Increases the callers stake on the target gateway.
Note: Requires signer
to be provided on ARIO.init
to sign the transaction.
const ario = ARIO.mainnet({ signer: new ArweaveSigner(jwk) });
const { id: txId } = await ario.increaseDelegateStake(
{
target: 't4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3',
qty: new ARIOToken(100).toMARIO(),
},
// optional additional tags
{ tags: [{ name: 'App-Name', value: 'My-Awesome-App' }] },
);
decreaseDelegateStake()
Decreases the callers stake on the target gateway. Can instantly decrease stake by setting instant to true
.
Note: Requires signer
to be provided on ARIO.init
to sign the transaction.
const ario = ARIO.mainnet({ signer: new ArweaveSigner(jwk) });
const { id: txId } = await ario.decreaseDelegateStake(
{
target: 't4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3',
qty: new ARIOToken(100).toMARIO(),
},
{
tags: [{ name: 'App-Name', value: 'My-Awesome-App' }],
},
);
Pay the early withdrawal fee and withdraw instantly.
const ario = ARIO.mainnet({ signer: new ArweaveSigner(jwk) });
const { id: txId } = await ario.decreaseDelegateStake({
target: 't4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3',
qty: new ARIOToken(100).toMARIO(),
instant: true, // Immediately withdraw this stake and pay the instant withdrawal fee
});
getDelegations()
Retrieves all active and vaulted stakes across all gateways for a specific address, paginated and sorted by the specified criteria. The cursor
used for pagination is the last delegationId (concatenated gateway and startTimestamp of the delgation) from the previous request.
const ario = ARIO.mainnet();
const vaults = await ario.getDelegations({
address: 't4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3',
cursor: 'QGWqtJdLLgm2ehFWiiPzMaoFLD50CnGuzZIPEdoDRGQ_123456789',
limit: 2,
sortBy: 'startTimestamp',
sortOrder: 'asc',
});
Output:
{
"sortOrder": "asc",
"hasMore": true,
"totalItems": 95,
"limit": 2,
"sortBy": "startTimestamp",
"items": [
{
"type": "stake",
"startTimestamp": 1727815440632,
"gatewayAddress": "QGWqtJdLLgm2ehFWiiPzMaoFLD50CnGuzZIPEdoDRGQ",
"delegationId": "QGWqtJdLLgm2ehFWiiPzMaoFLD50CnGuzZIPEdoDRGQ_1727815440632",
"balance": 1383212512
},
{
"type": "vault",
"startTimestamp": 1730996691117,
"gatewayAddress": "QGWqtJdLLgm2ehFWiiPzMaoFLD50CnGuzZIPEdoDRGQ",
"delegationId": "QGWqtJdLLgm2ehFWiiPzMaoFLD50CnGuzZIPEdoDRGQ_1730996691117",
"vaultId": "_sGDS7X1hyLCVpfe40GWioH9BSOb7f0XWbhHBa1q4-g",
"balance": 50000000,
"endTimestamp": 1733588691117
}
],
"nextCursor": "QGWqtJdLLgm2ehFWiiPzMaoFLD50CnGuzZIPEdoDRGQ_1730996691117"
}
instantWithdrawal()
Instantly withdraws an existing vault on a gateway. If no gatewayAddress
is provided, the signer's address will be used.
Note: Requires signer
to be provided on ARIO.init
to sign the transaction.
const ario = ARIO.mainnet({ signer: new ArweaveSigner(jwk) });
// removes a delegated vault from a gateway
const { id: txId } = await ario.instantWithdrawal(
{
// gateway address where delegate vault exists
gatewayAddress: 't4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3',
// delegated vault id to cancel
vaultId: 'fDrr0_J4Iurt7caNST02cMotaz2FIbWQ4Kcj616RHl3',
},
// optional additional tags
{
tags: [{ name: 'App-Name', value: 'My-Awesome-App' }],
},
);
// removes an operator vault from a gateway
const { id: txId } = await ario.instantWithdrawal(
{
vaultId: 'fDrr0_J4Iurt7caNST02cMotaz2FIbWQ4Kcj616RHl3',
},
);
cancelWithdrawal()
Cancels an existing vault on a gateway. The vaulted stake will be returned to the callers stake. If no gatewayAddress
is provided, the signer's address will be used.
Note: Requires signer
to be provided on ARIO.init
to sign the transaction.
const ario = ARIO.mainnet({ signer: new ArweaveSigner(jwk) });
// cancels a delegated vault from a gateway
const { id: txId } = await ario.cancelWithdrawal(
{
// gateway address where vault exists
gatewayAddress: 't4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3',
// vault id to cancel
vaultId: 'fDrr0_J4Iurt7caNST02cMotaz2FIbWQ4Kcj616RHl3',
},
// optional additional tags
{ tags: [{ name: 'App-Name', value: 'My-Awesome-App' }] },
);
// cancels an operator vault from a gateway
const { id: txId } = await ario.cancelWithdrawal(
{
// operator vault id to cancel
vaultId: 'fDrr0_J4Iurt7caNST02cMotaz2FIbWQ4Kcj616RHl3',
},
);
getAllowedDelegates()
Retrieves all allowed delegates for a specific address. The cursor
used for pagination is the last address from the previous request.
const ario = ARIO.mainnet();
const allowedDelegates = await ario.getAllowedDelegates({
address: 'QGWqtJdLLgm2ehFWiiPzMaoFLD50CnGuzZIPEdoDRGQ',
});
Output:
{
"sortOrder": "desc",
"hasMore": false,
"totalItems": 4,
"limit": 100,
"items": [
"PZ5vIhHf8VY969TxBPQN-rYY9CNFP9ggNsMBqlWUzWM",
"N4h8M9A9hasa3tF47qQyNvcKjm4APBKuFs7vqUVm-SI",
"JcC4ZLUY76vmWha5y6RwKsFqYTrMZhbockl8iM9p5lQ",
"31LPFYoow2G7j-eSSsrIh8OlNaARZ84-80J-8ba68d8"
]
}
getGatewayVaults()
Retrieves all vaults across all gateways for a specific address, paginated and sorted by the specified criteria. The cursor
used for pagination is the last vaultId from the previous request.
const ario = ARIO.mainnet();
const vaults = await ario.getGatewayVaults({
address: '"PZ5vIhHf8VY969TxBPQN-rYY9CNFP9ggNsMBqlWUzWM',
});
Output:
{
"sortOrder": "desc",
"hasMore": false,
"totalItems": 1,
"limit": 100,
"sortBy": "endTimestamp",
"items": [
{
"cursorId": "PZ5vIhHf8VY969TxBPQN-rYY9CNFP9ggNsMBqlWUzWM_1728067635857",
"startTimestamp": 1728067635857,
"balance": 50000000000,
"vaultId": "PZ5vIhHf8VY969TxBPQN-rYY9CNFP9ggNsMBqlWUzWM",
"endTimestamp": 1735843635857
}
]
}
getAllGatewayVaults()
Retrieves all vaults across all gateways, paginated and sorted by the specified criteria. The cursor
used for pagination is the last vaultId from the previous request.
const ario = ARIO.mainnet();
const vaults = await ario.getAllGatewayVaults({
limit: 1,
sortBy: 'endTimestamp',
sortOrder: 'desc',
});
Output:
{
"sortOrder": "desc",
"hasMore": true,
"totalItems": 95,
"limit": 1,
"sortBy": "endTimestamp",
"items": [
{
"cursorId": "PZ5vIhHf8VY969TxBPQN-rYY9CNFP9ggNsMBqlWUzWM_E-QVU3dta36Wia2uQw6tQLjQk7Qw5uN0Z6fUzsoqzUc",
"gatewayAddress": "PZ5vIhHf8VY969TxBPQN-rYY9CNFP9ggNsMBqlWUzWM",
"startTimestamp": 1728067635857,
"balance": 50000000000,
"vaultId": "E-QVU3dta36Wia2uQw6tQLjQk7Qw5uN0Z6fUzsoqzUc",
"endTimestamp": 1735843635857
}
],
"nextCursor": "PZ5vIhHf8VY969TxBPQN-rYY9CNFP9ggNsMBqlWUzWM_E-QVU3dta36Wia2uQw6tQLjQk7Qw5uN0Z6fUzsoqzUc"
}
increaseOperatorStake()
Increases the callers operator stake. Must be executed with a wallet registered as a gateway operator.
Note: Requires signer
to be provided on ARIO.init
to sign the transaction.
const ario = ARIO.mainnet({ signer: new ArweaveSigner(jwk) });
const { id: txId } = await ario.increaseOperatorStake(
{
qty: new ARIOToken(100).toMARIO(),
},
{
tags: [{ name: 'App-Name', value: 'My-Awesome-App' }],
},
);
decreaseOperatorStake()
Decreases the callers operator stake. Must be executed with a wallet registered as a gateway operator. Requires signer
to be provided on ARIO.init
to sign the transaction.
Note: Requires signer
to be provided on ARIO.init
to sign the transaction.
const ario = ARIO.mainnet({ signer: new ArweaveSigner(jwk) });
const { id: txId } = await ario.decreaseOperatorStake(
{
qty: new ARIOToken(100).toMARIO(),
},
{
tags: [{ name: 'App-Name', value: 'My-Awesome-App' }],
},
);
redelegateStake()
Redelegates the stake of a specific address to a new gateway. Vault ID may be optionally included in order to redelegate from an existing withdrawal vault. The redelegation fee is calculated based on the fee rate and the stake amount. Users are allowed one free redelegation every seven epochs. Each additional redelegation beyond the free redelegation will increase the fee by 10%, capping at a 60% redelegation fee.
e.g: If 1000 mARIO is redelegated and the fee rate is 10%, the fee will be 100 mARIO. Resulting in 900 mARIO being redelegated to the new gateway and 100 mARIO being deducted back to the protocol balance.
const ario = ARIO.mainnet({ signer: new ArweaveSigner(jwk) });
const { id: txId } = await ario.redelegateStake({
target: 't4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3',
source: 'HwFceQaMQnOBgKDpnFqCqgwKwEU5LBme1oXRuQOWSRA',
stakeQty: new ARIOToken(1000).toMARIO(),
vaultId: 'fDrr0_J4Iurt7caNST02cMotaz2FIbWQ4Kcj616RHl3',
});
getRedelegationFee()
Retrieves the fee rate as percentage required to redelegate the stake of a specific address. Fee rate ranges from 0% to 60% based on the number of redelegations since the last fee reset.
const ario = ARIO.mainnet();
const fee = await ario.getRedelegationFee({
address: 't4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3',
});
Output:
{
"redelegationFeeRate": 10,
"feeResetTimestamp": 1730996691117
}
getAllDelegates()
Retrieves all delegates across all gateways, paginated and sorted by the specified criteria. The cursor
used for pagination is a cursorId
derived from delegate address and the gatewayAddress from the previous request. e.g address_gatewayAddress
.
const ario = ARIO.mainnet();
const delegates = await ario.getAllDelegates({
limit: 2,
sortBy: 'startTimestamp',
sortOrder: 'desc',
});
Output:
{
"sortOrder": "desc",
"hasMore": true,
"totalItems": 95,
"limit": 2,
"sortBy": "startTimestamp",
"items": [
{
"startTimestamp": 1734709397622,
"cursorId": "9jfM0uzGNc9Mkhjo1ixGoqM7ygSem9wx_EokiVgi0Bs_E-QVU3dta36Wia2uQw6tQLjQk7Qw5uN0Z6fUzsoqzUc",
"gatewayAddress": "E-QVU3dta36Wia2uQw6tQLjQk7Qw5uN0Z6fUzsoqzUc",
"address": "9jfM0uzGNc9Mkhjo1ixGoqM7ygSem9wx_EokiVgi0Bs",
"delegatedStake": 2521349108,
"vaultedStake": 0
},
{
"startTimestamp": 1734593229454,
"cursorId": "LtV0aSqgK3YI7c5FmfvZd-wG95TJ9sezj_a4syaLMS8_M0WP8KSzCvKpzC-HPF1WcddLgGaL9J4DGi76iMnhrN4",
"gatewayAddress": "M0WP8KSzCvKpzC-HPF1WcddLgGaL9J4DGi76iMnhrN4",
"address": "LtV0aSqgK3YI7c5FmfvZd-wG95TJ9sezj_a4syaLMS8",
"delegatedStake": 1685148110,
"vaultedStake": 10000000
}
],
"nextCursor": "PZ5vIhHf8VY969TxBPQN-rYY9CNFP9ggNsMBqlWUzWM_QGWqtJdLLgm2ehFWiiPzMaoFLD50CnGuzZIPEdoDRGQ"
}
How is this guide?