Skip to content

Nimiq JSON-RPC Specification

Through the use of JSON-RPC, Nimiq nodes expose a set of standardized methods and endpoints that allow external applications and tools to interact, stream and control the behavior of the nodes. This includes functionalities such as retrieving information about the blockchain state, submitting transactions, managing accounts, and configuring node settings.

Authentication

Authentication with the JSON-RPC server occurs via HTTP Basic Authentication. The username and password can be configured within the rpc-server section of the client.toml file. Authentication with the RPC server functions by adding an Authorization header to the HTTP request. The value of this header is provided in the format Basic <credentials> where credentials is a base64-encoded string containing the username and password separated by a colon.

Shell
echo -n 'super:secret' | base64
# Output: c3VwZXI6c2VjcmV0

curl --request POST \
    --url http://127.0.0.1:8648 \
    --header 'Authorization: Basic c3VwZXI6c2VjcmV0' \
    --header 'Content-Type: application/json' \
    --data '{
    "jsonrpc": "2.0",
    "method": "getLatestBlock",
    "params": [false],
    "id": 1
}'

Passing parameters to RPC methods

The JSON-RPC specification defines two ways of passing parameters to methods: named parameters, providing flexibility by labeling parameters, and positional parameters, relying on their order in the request. At the moment the JSON-RPC server implementation only supports positional parameters, meaning parameter order must match the server's expectation.

JSON
{
    "jsonrpc": "2.0",
    "params": {"hour": 12, "minutes": 30}, 
    "params": [12, 30], 
}

Methods

Validator

addVotingKey

Parameters

  • secretKey*: string

Returns

  • null
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "addVotingKey",
    "params": ["secretKey"],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "addVotingKey",
    "params": ["secretKey"],
    "id": 1
  }'

getAddress

Returns our validator address.

Parameters

Returns

  • string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getAddress",
    "params": [],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getAddress",
    "params": [],
    "id": 1
  }'

getSigningKey

Returns our validator signing key.

Parameters

Returns

  • string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getSigningKey",
    "params": [],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getSigningKey",
    "params": [],
    "id": 1
  }'

getVotingKey

Returns our current validator voting key.

Parameters

Returns

  • string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getVotingKey",
    "params": [],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getVotingKey",
    "params": [],
    "id": 1
  }'

getVotingKeys

Returns all available voting keys.

Parameters

Returns

  • array
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getVotingKeys",
    "params": [],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getVotingKeys",
    "params": [],
    "id": 1
  }'

isValidatorElected

Returns if our validator is currently elected.

Parameters

Returns

  • boolean
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "isValidatorElected",
    "params": [],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "isValidatorElected",
    "params": [],
    "id": 1
  }'

isValidatorSynced

Returns if our validator is currently synced.

Parameters

Returns

  • boolean
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "isValidatorSynced",
    "params": [],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "isValidatorSynced",
    "params": [],
    "id": 1
  }'

setAutomaticReactivation

Updates the configuration setting to automatically reactivate our validator.

Parameters

  • automaticReactivate*: boolean

Returns

  • null
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "setAutomaticReactivation",
    "params": [false],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "setAutomaticReactivation",
    "params": [false],
    "id": 1
  }'

Wallet

createAccount

Generates a new account and store it.

Parameters

  • passphrase*: string

Returns

  • address*: string
  • publicKey*: string
  • privateKey*: string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "createAccount",
    "params": ["passphrase"],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "createAccount",
    "params": ["passphrase"],
    "id": 1
  }'

importRawKey

Import an account by its private key, in hexadecimal format, and lock it with the passphrase.

Parameters

  • keyData*: string
  • passphrase*: string

Returns

  • string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "importRawKey",
    "params": ["keyData", "passphrase"],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "importRawKey",
    "params": ["keyData", "passphrase"],
    "id": 1
  }'

isAccountImported

Returns if an account has been imported.

Parameters

  • address*: string

Returns

  • boolean
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "isAccountImported",
    "params": ["address"],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "isAccountImported",
    "params": ["address"],
    "id": 1
  }'

isAccountUnlocked

Returns if the account currently is unlocked.

Parameters

  • address*: string

Returns

  • boolean
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "isAccountUnlocked",
    "params": ["address"],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "isAccountUnlocked",
    "params": ["address"],
    "id": 1
  }'

listAccounts

Returns the accounts that have been imported.

Parameters

Returns

  • array
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "listAccounts",
    "params": [],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "listAccounts",
    "params": [],
    "id": 1
  }'

lockAccount

Locks the account to prevent further usage.

Parameters

  • address*: string

Returns

  • null
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "lockAccount",
    "params": ["address"],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "lockAccount",
    "params": ["address"],
    "id": 1
  }'

removeAccount

Removes an imported account. IMPORTANT: This action is irreversible, and the account can only be recovered with its private key.

Parameters

  • address*: string

Returns

  • boolean
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "removeAccount",
    "params": ["address"],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "removeAccount",
    "params": ["address"],
    "id": 1
  }'

sign

Parameters

  • message*: string
  • address*: string
  • passphrase*: string
  • isHex*: boolean

Returns

  • publicKey*: string
  • signature*: string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "sign",
    "params": ["message", "address", "passphrase", false],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "sign",
    "params": ["message", "address", "passphrase", false],
    "id": 1
  }'

unlockAccount

Unlocks the account.

Parameters

  • address*: string
  • passphrase*: string
  • duration*: number

Returns

  • boolean
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "unlockAccount",
    "params": ["address", "passphrase", 0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "unlockAccount",
    "params": ["address", "passphrase", 0],
    "id": 1
  }'

verifySignature

Verifies the signature based on the provided public key and message.

Parameters

  • message*: string
  • publicKey*: string
  • signature*: string
  • isHex*: boolean

Returns

  • boolean
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "verifySignature",
    "params": ["message", "publicKey", "signature", false],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "verifySignature",
    "params": ["message", "publicKey", "signature", false],
    "id": 1
  }'

Consensus

createBasicTransaction

Returns a serialized basic transaction.

Parameters

  • wallet*: string
  • recipient*: string
  • value*: number
  • fee*: number
  • validityStartHeight*: number

Returns

  • string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "createBasicTransaction",
    "params": ["wallet", "recipient", 0, 0, 0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "createBasicTransaction",
    "params": ["wallet", "recipient", 0, 0, 0],
    "id": 1
  }'

createBasicTransactionWithData

Returns a serialized basic transaction with an arbitrary data field.

Parameters

  • wallet*: string
  • recipient*: string
  • data*: string
  • value*: number
  • fee*: number
  • validityStartHeight*: number

Returns

  • string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "createBasicTransactionWithData",
    "params": ["wallet", "recipient", "data", 0, 0, 0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "createBasicTransactionWithData",
    "params": ["wallet", "recipient", "data", 0, 0, 0],
    "id": 1
  }'

createDeactivateValidatorTransaction

Returns a serialized deactivate_validator transaction. You need to provide the address of a basic account (the sender wallet) to pay the transaction fee.

Parameters

  • senderWallet*: string
  • validatorAddress*: string
  • signingSecretKey*: string
  • fee*: number
  • validityStartHeight*: number

Returns

  • string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "createDeactivateValidatorTransaction",
    "params": ["senderWallet", "validatorAddress", "signingSecretKey", 0, 0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "createDeactivateValidatorTransaction",
    "params": ["senderWallet", "validatorAddress", "signingSecretKey", 0, 0],
    "id": 1
  }'

createDeleteValidatorTransaction

Returns a serialized delete_validator transaction. The transaction fee will be paid from the validator deposit that is being returned. Note in order for this transaction to be accepted fee + value should be equal to the validator deposit, which is not a fixed value: Failed delete validator transactions can diminish the validator deposit

Parameters

  • validatorWallet*: string
  • recipient*: string
  • fee*: number
  • value*: number
  • validityStartHeight*: number

Returns

  • string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "createDeleteValidatorTransaction",
    "params": ["validatorWallet", "recipient", 0, 0, 0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "createDeleteValidatorTransaction",
    "params": ["validatorWallet", "recipient", 0, 0, 0],
    "id": 1
  }'

createNewHtlcTransaction

Returns a serialized transaction creating a new HTLC contract.

Parameters

  • wallet*: string
  • htlcSender*: string
  • htlcRecipient*: string
  • hashRoot*: string
  • hashCount*: number
  • timeout*: number
  • value*: number
  • fee*: number
  • validityStartHeight*: number

Returns

  • string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "createNewHtlcTransaction",
    "params": ["wallet", "htlcSender", "htlcRecipient", "hashRoot", 0, 0, 0, 0, 0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "createNewHtlcTransaction",
    "params": ["wallet", "htlcSender", "htlcRecipient", "hashRoot", 0, 0, 0, 0, 0],
    "id": 1
  }'

createNewStakerTransaction

Returns a serialized new_staker transaction. You need to provide the address of a basic account (the sender wallet) to pay the transaction fee.

Parameters

  • senderWallet*: string
  • stakerWallet*: string
  • delegation*: string
  • value*: number
  • fee*: number
  • validityStartHeight*: number

Returns

  • string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "createNewStakerTransaction",
    "params": ["senderWallet", "stakerWallet", "delegation", 0, 0, 0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "createNewStakerTransaction",
    "params": ["senderWallet", "stakerWallet", "delegation", 0, 0, 0],
    "id": 1
  }'

createNewValidatorTransaction

Returns a serialized new_validator transaction. You need to provide the address of a basic account (the sender wallet) to pay the transaction fee and the validator deposit. Since JSON doesn't have a primitive for Option (it just has the null primitive), we can't have a double Option. So we use the following work-around for the signal data: "" = Set the signal data field to None. "0x29a4b..." = Set the signal data field to Some(0x29a4b...).

Parameters

  • senderWallet*: string
  • validatorWallet*: string
  • signingSecretKey*: string
  • votingSecretKey*: string
  • rewardAddress*: string
  • signalData*: string
  • fee*: number
  • validityStartHeight*: number

Returns

  • string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "createNewValidatorTransaction",
    "params": ["senderWallet", "validatorWallet", "signingSecretKey", "votingSecretKey", "rewardAddress", "signalData", 0, 0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "createNewValidatorTransaction",
    "params": ["senderWallet", "validatorWallet", "signingSecretKey", "votingSecretKey", "rewardAddress", "signalData", 0, 0],
    "id": 1
  }'

createNewVestingTransaction

Returns a serialized transaction creating a new vesting contract.

Parameters

  • wallet*: string
  • owner*: string
  • startTime*: number
  • timeStep*: number
  • numSteps*: number
  • value*: number
  • fee*: number
  • validityStartHeight*: number

Returns

  • string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "createNewVestingTransaction",
    "params": ["wallet", "owner", 0, 0, 0, 0, 0, 0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "createNewVestingTransaction",
    "params": ["wallet", "owner", 0, 0, 0, 0, 0, 0],
    "id": 1
  }'

createReactivateValidatorTransaction

Returns a serialized reactivate_validator transaction. You need to provide the address of a basic account (the sender wallet) to pay the transaction fee.

Parameters

  • senderWallet*: string
  • validatorAddress*: string
  • signingSecretKey*: string
  • fee*: number
  • validityStartHeight*: number

Returns

  • string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "createReactivateValidatorTransaction",
    "params": ["senderWallet", "validatorAddress", "signingSecretKey", 0, 0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "createReactivateValidatorTransaction",
    "params": ["senderWallet", "validatorAddress", "signingSecretKey", 0, 0],
    "id": 1
  }'

createRedeemEarlyHtlcTransaction

Returns a serialized transaction redeeming a HTLC contract using the EarlyResolve method.

Parameters

  • contractAddress*: string
  • recipient*: string
  • htlcSenderSignature*: string
  • htlcRecipientSignature*: string
  • value*: number
  • fee*: number
  • validityStartHeight*: number

Returns

  • string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "createRedeemEarlyHtlcTransaction",
    "params": ["contractAddress", "recipient", "htlcSenderSignature", "htlcRecipientSignature", 0, 0, 0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "createRedeemEarlyHtlcTransaction",
    "params": ["contractAddress", "recipient", "htlcSenderSignature", "htlcRecipientSignature", 0, 0, 0],
    "id": 1
  }'

createRedeemRegularHtlcTransaction

Returns a serialized transaction redeeming a HTLC contract using the RegularTransfer method.

Parameters

  • wallet*: string
  • contractAddress*: string
  • recipient*: string
  • preImage*: string
  • hashRoot*: string
  • hashCount*: number
  • value*: number
  • fee*: number
  • validityStartHeight*: number

Returns

  • string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "createRedeemRegularHtlcTransaction",
    "params": ["wallet", "contractAddress", "recipient", "preImage", "hashRoot", 0, 0, 0, 0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "createRedeemRegularHtlcTransaction",
    "params": ["wallet", "contractAddress", "recipient", "preImage", "hashRoot", 0, 0, 0, 0],
    "id": 1
  }'

createRedeemTimeoutHtlcTransaction

Returns a serialized transaction redeeming a HTLC contract using the TimeoutResolve method.

Parameters

  • wallet*: string
  • contractAddress*: string
  • recipient*: string
  • value*: number
  • fee*: number
  • validityStartHeight*: number

Returns

  • string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "createRedeemTimeoutHtlcTransaction",
    "params": ["wallet", "contractAddress", "recipient", 0, 0, 0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "createRedeemTimeoutHtlcTransaction",
    "params": ["wallet", "contractAddress", "recipient", 0, 0, 0],
    "id": 1
  }'

createRedeemVestingTransaction

Returns a serialized transaction redeeming a vesting contract.

Parameters

  • wallet*: string
  • contractAddress*: string
  • recipient*: string
  • value*: number
  • fee*: number
  • validityStartHeight*: number

Returns

  • string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "createRedeemVestingTransaction",
    "params": ["wallet", "contractAddress", "recipient", 0, 0, 0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "createRedeemVestingTransaction",
    "params": ["wallet", "contractAddress", "recipient", 0, 0, 0],
    "id": 1
  }'

createRemoveStakeTransaction

Returns a serialized remove_stake transaction. The transaction fee will be paid from the funds being removed.

Parameters

  • stakerWallet*: string
  • recipient*: string
  • value*: number
  • fee*: number
  • validityStartHeight*: number

Returns

  • string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "createRemoveStakeTransaction",
    "params": ["stakerWallet", "recipient", 0, 0, 0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "createRemoveStakeTransaction",
    "params": ["stakerWallet", "recipient", 0, 0, 0],
    "id": 1
  }'

createRetireStakeTransaction

Returns a serialized retire_stake transaction. You can pay the transaction fee from a basic account (by providing the sender wallet) or from the staker account's balance (by not providing a sender wallet).

Parameters

  • senderWallet*: string
  • stakerWallet*: string
  • retireStake*: number
  • fee*: number
  • validityStartHeight*: number

Returns

  • string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "createRetireStakeTransaction",
    "params": ["senderWallet", "stakerWallet", 0, 0, 0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "createRetireStakeTransaction",
    "params": ["senderWallet", "stakerWallet", 0, 0, 0],
    "id": 1
  }'

createRetireValidatorTransaction

Returns a serialized retire_validator transaction. You need to provide the address of a basic account (the sender wallet) to pay the transaction fee.

Parameters

  • senderWallet*: string
  • validatorWallet*: string
  • fee*: number
  • validityStartHeight*: number

Returns

  • string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "createRetireValidatorTransaction",
    "params": ["senderWallet", "validatorWallet", 0, 0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "createRetireValidatorTransaction",
    "params": ["senderWallet", "validatorWallet", 0, 0],
    "id": 1
  }'

createSetActiveStakeTransaction

Returns a serialized set_active_stake transaction. You can pay the transaction fee from a basic account (by providing the sender wallet) or from the staker account's balance (by not providing a sender wallet).

Parameters

  • senderWallet*: string
  • stakerWallet*: string
  • newActiveBalance*: number
  • fee*: number
  • validityStartHeight*: number

Returns

  • string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "createSetActiveStakeTransaction",
    "params": ["senderWallet", "stakerWallet", 0, 0, 0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "createSetActiveStakeTransaction",
    "params": ["senderWallet", "stakerWallet", 0, 0, 0],
    "id": 1
  }'

createStakeTransaction

Returns a serialized stake transaction. The funds to be staked and the transaction fee will be paid from the sender_wallet.

Parameters

  • senderWallet*: string
  • stakerAddress*: string
  • value*: number
  • fee*: number
  • validityStartHeight*: number

Returns

  • string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "createStakeTransaction",
    "params": ["senderWallet", "stakerAddress", 0, 0, 0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "createStakeTransaction",
    "params": ["senderWallet", "stakerAddress", 0, 0, 0],
    "id": 1
  }'

createUpdateStakerTransaction

Returns a serialized update_staker transaction. You can pay the transaction fee from a basic account (by providing the sender wallet) or from the staker account's balance (by not providing a sender wallet).

Parameters

  • senderWallet*: string
  • stakerWallet*: string
  • newDelegation*: string
  • reactivateAllStake*: boolean
  • fee*: number
  • validityStartHeight*: number

Returns

  • string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "createUpdateStakerTransaction",
    "params": ["senderWallet", "stakerWallet", "newDelegation", false, 0, 0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "createUpdateStakerTransaction",
    "params": ["senderWallet", "stakerWallet", "newDelegation", false, 0, 0],
    "id": 1
  }'

createUpdateValidatorTransaction

Returns a serialized update_validator transaction. You need to provide the address of a basic account (the sender wallet) to pay the transaction fee. Since JSON doesn't have a primitive for Option (it just has the null primitive), we can't have a double Option. So we use the following work-around for the signal data: null = No change in the signal data field. "" = Change the signal data field to None. "0x29a4b..." = Change the signal data field to Some(0x29a4b...).

Parameters

  • senderWallet*: string
  • validatorWallet*: string
  • newSigningSecretKey*: string
  • newVotingSecretKey*: string
  • newRewardAddress*: string
  • newSignalData*: string
  • fee*: number
  • validityStartHeight*: number

Returns

  • string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "createUpdateValidatorTransaction",
    "params": ["senderWallet", "validatorWallet", "newSigningSecretKey", "newVotingSecretKey", "newRewardAddress", "newSignalData", 0, 0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "createUpdateValidatorTransaction",
    "params": ["senderWallet", "validatorWallet", "newSigningSecretKey", "newVotingSecretKey", "newRewardAddress", "newSignalData", 0, 0],
    "id": 1
  }'

getRawTransactionInfo

Given a serialized transaction, it will return the corresponding transaction struct.

Parameters

  • rawTx*: string

Returns

  • hash*: string
  • blockNumber: number
  • timestamp: number
  • confirmations: number
  • size*: number
  • relatedAddresses*: object
  • from*: string
  • fromType*: number
  • to*: string
  • toType*: number
  • value*: number
  • fee*: number
  • senderData*: array
  • recipientData*: array
  • flags*: number
  • validityStartHeight*: number
  • proof*: array
  • networkId*: number
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getRawTransactionInfo",
    "params": ["rawTx"],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getRawTransactionInfo",
    "params": ["rawTx"],
    "id": 1
  }'

isConsensusEstablished

Returns a boolean specifying if we have established consensus with the network.

Parameters

Returns

  • boolean
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "isConsensusEstablished",
    "params": [],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "isConsensusEstablished",
    "params": [],
    "id": 1
  }'

sendBasicTransaction

Sends a basic transaction to the network.

Parameters

  • wallet*: string
  • recipient*: string
  • value*: number
  • fee*: number
  • validityStartHeight*: number

Returns

  • string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "sendBasicTransaction",
    "params": ["wallet", "recipient", 0, 0, 0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "sendBasicTransaction",
    "params": ["wallet", "recipient", 0, 0, 0],
    "id": 1
  }'

sendBasicTransactionWithData

Sends a basic transaction, with an arbitrary data field, to the network.

Parameters

  • wallet*: string
  • recipient*: string
  • data*: string
  • value*: number
  • fee*: number
  • validityStartHeight*: number

Returns

  • string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "sendBasicTransactionWithData",
    "params": ["wallet", "recipient", "data", 0, 0, 0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "sendBasicTransactionWithData",
    "params": ["wallet", "recipient", "data", 0, 0, 0],
    "id": 1
  }'

sendDeactivateValidatorTransaction

Sends a deactivate_validator transaction to the network. You need to provide the address of a basic account (the sender wallet) to pay the transaction fee.

Parameters

  • senderWallet*: string
  • validatorAddress*: string
  • signingSecretKey*: string
  • fee*: number
  • validityStartHeight*: number

Returns

  • string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "sendDeactivateValidatorTransaction",
    "params": ["senderWallet", "validatorAddress", "signingSecretKey", 0, 0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "sendDeactivateValidatorTransaction",
    "params": ["senderWallet", "validatorAddress", "signingSecretKey", 0, 0],
    "id": 1
  }'

sendDeleteValidatorTransaction

Sends a delete_validator transaction to the network. The transaction fee will be paid from the validator deposit that is being returned.

Parameters

  • validatorWallet*: string
  • recipient*: string
  • fee*: number
  • value*: number
  • validityStartHeight*: number

Returns

  • string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "sendDeleteValidatorTransaction",
    "params": ["validatorWallet", "recipient", 0, 0, 0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "sendDeleteValidatorTransaction",
    "params": ["validatorWallet", "recipient", 0, 0, 0],
    "id": 1
  }'

sendNewHtlcTransaction

Sends a transaction creating a new HTLC contract to the network.

Parameters

  • wallet*: string
  • htlcSender*: string
  • htlcRecipient*: string
  • hashRoot*: string
  • hashCount*: number
  • timeout*: number
  • value*: number
  • fee*: number
  • validityStartHeight*: number

Returns

  • string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "sendNewHtlcTransaction",
    "params": ["wallet", "htlcSender", "htlcRecipient", "hashRoot", 0, 0, 0, 0, 0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "sendNewHtlcTransaction",
    "params": ["wallet", "htlcSender", "htlcRecipient", "hashRoot", 0, 0, 0, 0, 0],
    "id": 1
  }'

sendNewStakerTransaction

Sends a new_staker transaction to the network. You need to provide the address of a basic account (the sender wallet) to pay the transaction fee.

Parameters

  • senderWallet*: string
  • stakerWallet*: string
  • delegation*: string
  • value*: number
  • fee*: number
  • validityStartHeight*: number

Returns

  • string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "sendNewStakerTransaction",
    "params": ["senderWallet", "stakerWallet", "delegation", 0, 0, 0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "sendNewStakerTransaction",
    "params": ["senderWallet", "stakerWallet", "delegation", 0, 0, 0],
    "id": 1
  }'

sendNewValidatorTransaction

Sends a new_validator transaction to the network. You need to provide the address of a basic account (the sender wallet) to pay the transaction fee and the validator deposit. Since JSON doesn't have a primitive for Option (it just has the null primitive), we can't have a double Option. So we use the following work-around for the signal data: "" = Set the signal data field to None. "0x29a4b..." = Set the signal data field to Some(0x29a4b...).

Parameters

  • senderWallet*: string
  • validatorWallet*: string
  • signingSecretKey*: string
  • votingSecretKey*: string
  • rewardAddress*: string
  • signalData*: string
  • fee*: number
  • validityStartHeight*: number

Returns

  • string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "sendNewValidatorTransaction",
    "params": ["senderWallet", "validatorWallet", "signingSecretKey", "votingSecretKey", "rewardAddress", "signalData", 0, 0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "sendNewValidatorTransaction",
    "params": ["senderWallet", "validatorWallet", "signingSecretKey", "votingSecretKey", "rewardAddress", "signalData", 0, 0],
    "id": 1
  }'

sendNewVestingTransaction

Sends a transaction creating a new vesting contract to the network.

Parameters

  • wallet*: string
  • owner*: string
  • startTime*: number
  • timeStep*: number
  • numSteps*: number
  • value*: number
  • fee*: number
  • validityStartHeight*: number

Returns

  • string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "sendNewVestingTransaction",
    "params": ["wallet", "owner", 0, 0, 0, 0, 0, 0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "sendNewVestingTransaction",
    "params": ["wallet", "owner", 0, 0, 0, 0, 0, 0],
    "id": 1
  }'

sendRawTransaction

Sends the given serialized transaction to the network.

Parameters

  • rawTx*: string

Returns

  • string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "sendRawTransaction",
    "params": ["rawTx"],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "sendRawTransaction",
    "params": ["rawTx"],
    "id": 1
  }'

sendReactivateValidatorTransaction

Sends a reactivate_validator transaction to the network. You need to provide the address of a basic account (the sender wallet) to pay the transaction fee.

Parameters

  • senderWallet*: string
  • validatorAddress*: string
  • signingSecretKey*: string
  • fee*: number
  • validityStartHeight*: number

Returns

  • string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "sendReactivateValidatorTransaction",
    "params": ["senderWallet", "validatorAddress", "signingSecretKey", 0, 0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "sendReactivateValidatorTransaction",
    "params": ["senderWallet", "validatorAddress", "signingSecretKey", 0, 0],
    "id": 1
  }'

sendRedeemEarlyHtlcTransaction

Sends a transaction redeeming a HTLC contract, using the EarlyResolve method, to the network.

Parameters

  • contractAddress*: string
  • recipient*: string
  • htlcSenderSignature*: string
  • htlcRecipientSignature*: string
  • value*: number
  • fee*: number
  • validityStartHeight*: number

Returns

  • string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "sendRedeemEarlyHtlcTransaction",
    "params": ["contractAddress", "recipient", "htlcSenderSignature", "htlcRecipientSignature", 0, 0, 0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "sendRedeemEarlyHtlcTransaction",
    "params": ["contractAddress", "recipient", "htlcSenderSignature", "htlcRecipientSignature", 0, 0, 0],
    "id": 1
  }'

sendRedeemRegularHtlcTransaction

Sends a transaction redeeming a HTLC contract, using the RegularTransfer method, to the network.

Parameters

  • wallet*: string
  • contractAddress*: string
  • recipient*: string
  • preImage*: string
  • hashRoot*: string
  • hashCount*: number
  • value*: number
  • fee*: number
  • validityStartHeight*: number

Returns

  • string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "sendRedeemRegularHtlcTransaction",
    "params": ["wallet", "contractAddress", "recipient", "preImage", "hashRoot", 0, 0, 0, 0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "sendRedeemRegularHtlcTransaction",
    "params": ["wallet", "contractAddress", "recipient", "preImage", "hashRoot", 0, 0, 0, 0],
    "id": 1
  }'

sendRedeemTimeoutHtlcTransaction

Sends a transaction redeeming a HTLC contract, using the TimeoutResolve method, to the network.

Parameters

  • wallet*: string
  • contractAddress*: string
  • recipient*: string
  • value*: number
  • fee*: number
  • validityStartHeight*: number

Returns

  • string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "sendRedeemTimeoutHtlcTransaction",
    "params": ["wallet", "contractAddress", "recipient", 0, 0, 0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "sendRedeemTimeoutHtlcTransaction",
    "params": ["wallet", "contractAddress", "recipient", 0, 0, 0],
    "id": 1
  }'

sendRedeemVestingTransaction

Sends a transaction redeeming a vesting contract to the network.

Parameters

  • wallet*: string
  • contractAddress*: string
  • recipient*: string
  • value*: number
  • fee*: number
  • validityStartHeight*: number

Returns

  • string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "sendRedeemVestingTransaction",
    "params": ["wallet", "contractAddress", "recipient", 0, 0, 0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "sendRedeemVestingTransaction",
    "params": ["wallet", "contractAddress", "recipient", 0, 0, 0],
    "id": 1
  }'

sendRemoveStakeTransaction

Sends a remove_stake transaction to the network. The transaction fee will be paid from the funds being removed.

Parameters

  • stakerWallet*: string
  • recipient*: string
  • value*: number
  • fee*: number
  • validityStartHeight*: number

Returns

  • string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "sendRemoveStakeTransaction",
    "params": ["stakerWallet", "recipient", 0, 0, 0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "sendRemoveStakeTransaction",
    "params": ["stakerWallet", "recipient", 0, 0, 0],
    "id": 1
  }'

sendRetireStakeTransaction

Sends a retire_stake transaction to the network. You can pay the transaction fee from a basic account (by providing the sender wallet) or from the staker account's balance (by not providing a sender wallet).

Parameters

  • senderWallet*: string
  • stakerWallet*: string
  • retireStake*: number
  • fee*: number
  • validityStartHeight*: number

Returns

  • string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "sendRetireStakeTransaction",
    "params": ["senderWallet", "stakerWallet", 0, 0, 0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "sendRetireStakeTransaction",
    "params": ["senderWallet", "stakerWallet", 0, 0, 0],
    "id": 1
  }'

sendRetireValidatorTransaction

Sends a retire_validator transaction to the network. You need to provide the address of a basic account (the sender wallet) to pay the transaction fee.

Parameters

  • senderWallet*: string
  • validatorWallet*: string
  • fee*: number
  • validityStartHeight*: number

Returns

  • string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "sendRetireValidatorTransaction",
    "params": ["senderWallet", "validatorWallet", 0, 0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "sendRetireValidatorTransaction",
    "params": ["senderWallet", "validatorWallet", 0, 0],
    "id": 1
  }'

sendSetActiveStakeTransaction

Sends a set_active_stake transaction to the network. You can pay the transaction fee from a basic account (by providing the sender wallet) or from the staker account's balance (by not providing a sender wallet).

Parameters

  • senderWallet*: string
  • stakerWallet*: string
  • newActiveBalance*: number
  • fee*: number
  • validityStartHeight*: number

Returns

  • string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "sendSetActiveStakeTransaction",
    "params": ["senderWallet", "stakerWallet", 0, 0, 0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "sendSetActiveStakeTransaction",
    "params": ["senderWallet", "stakerWallet", 0, 0, 0],
    "id": 1
  }'

sendStakeTransaction

Sends a stake transaction to the network. The funds to be staked and the transaction fee will be paid from the sender_wallet.

Parameters

  • senderWallet*: string
  • stakerAddress*: string
  • value*: number
  • fee*: number
  • validityStartHeight*: number

Returns

  • string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "sendStakeTransaction",
    "params": ["senderWallet", "stakerAddress", 0, 0, 0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "sendStakeTransaction",
    "params": ["senderWallet", "stakerAddress", 0, 0, 0],
    "id": 1
  }'

sendUpdateStakerTransaction

Sends a update_staker transaction to the network. You can pay the transaction fee from a basic account (by providing the sender wallet) or from the staker account's balance (by not providing a sender wallet).

Parameters

  • senderWallet*: string
  • stakerWallet*: string
  • newDelegation*: string
  • reactivateAllStake*: boolean
  • fee*: number
  • validityStartHeight*: number

Returns

  • string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "sendUpdateStakerTransaction",
    "params": ["senderWallet", "stakerWallet", "newDelegation", false, 0, 0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "sendUpdateStakerTransaction",
    "params": ["senderWallet", "stakerWallet", "newDelegation", false, 0, 0],
    "id": 1
  }'

sendUpdateValidatorTransaction

Sends a update_validator transaction to the network. You need to provide the address of a basic account (the sender wallet) to pay the transaction fee. Since JSON doesn't have a primitive for Option (it just has the null primitive), we can't have a double Option. So we use the following work-around for the signal data: null = No change in the signal data field. "" = Change the signal data field to None. "0x29a4b..." = Change the signal data field to Some(0x29a4b...).

Parameters

  • senderWallet*: string
  • validatorWallet*: string
  • newSigningSecretKey*: string
  • newVotingSecretKey*: string
  • newRewardAddress*: string
  • newSignalData*: string
  • fee*: number
  • validityStartHeight*: number

Returns

  • string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "sendUpdateValidatorTransaction",
    "params": ["senderWallet", "validatorWallet", "newSigningSecretKey", "newVotingSecretKey", "newRewardAddress", "newSignalData", 0, 0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "sendUpdateValidatorTransaction",
    "params": ["senderWallet", "validatorWallet", "newSigningSecretKey", "newVotingSecretKey", "newRewardAddress", "newSignalData", 0, 0],
    "id": 1
  }'

signRedeemEarlyHtlcTransaction

Returns a serialized signature that can be used to redeem funds from a HTLC contract using the EarlyResolve method.

Parameters

  • wallet*: string
  • contractAddress*: string
  • recipient*: string
  • value*: number
  • fee*: number
  • validityStartHeight*: number

Returns

  • string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "signRedeemEarlyHtlcTransaction",
    "params": ["wallet", "contractAddress", "recipient", 0, 0, 0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "signRedeemEarlyHtlcTransaction",
    "params": ["wallet", "contractAddress", "recipient", 0, 0, 0],
    "id": 1
  }'

Blockchain

getAccountByAddress

Tries to fetch the account at the given address.

Parameters

  • address*: string

Returns

  • address*: string
  • balance*: number
  • accountAdditionalFields*: object
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getAccountByAddress",
    "params": ["address"],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getAccountByAddress",
    "params": ["address"],
    "id": 1
  }'

getAccounts

Fetches all accounts in the accounts tree. IMPORTANT: This operation iterates over all accounts in the accounts tree and thus is extremely computationally expensive.

Parameters

Returns

  • array
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getAccounts",
    "params": [],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getAccounts",
    "params": [],
    "id": 1
  }'

getActiveValidators

Returns a collection of the currently active validator's addresses and balances.

Parameters

Returns

  • array
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getActiveValidators",
    "params": [],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getActiveValidators",
    "params": [],
    "id": 1
  }'

getBatchNumber

Returns the batch number for the current head.

Parameters

Returns

  • number
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getBatchNumber",
    "params": [],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getBatchNumber",
    "params": [],
    "id": 1
  }'

getBlockByHash

Tries to fetch a block given its hash. It has an option to include the transactions in the block, which defaults to false.

Parameters

  • hash*: string
  • includeBody*: boolean

Returns

  • hash*: string
  • size*: number
  • batch*: number
  • epoch*: number
  • network*: string
  • version*: number
  • number*: number
  • timestamp*: number
  • parentHash*: string
  • seed*: string
  • extraData*: array
  • stateHash*: string
  • bodyHash: string
  • historyHash*: string
  • transactions: array
  • additionalFields*: object
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getBlockByHash",
    "params": ["hash", false],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getBlockByHash",
    "params": ["hash", false],
    "id": 1
  }'

getBlockByNumber

Tries to fetch a block given its number. It has an option to include the transactions in the block, which defaults to false. Note that this function will only fetch blocks that are part of the main chain.

Parameters

  • blockNumber*: number
  • includeBody*: boolean

Returns

  • hash*: string
  • size*: number
  • batch*: number
  • epoch*: number
  • network*: string
  • version*: number
  • number*: number
  • timestamp*: number
  • parentHash*: string
  • seed*: string
  • extraData*: array
  • stateHash*: string
  • bodyHash: string
  • historyHash*: string
  • transactions: array
  • additionalFields*: object
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getBlockByNumber",
    "params": [0, false],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getBlockByNumber",
    "params": [0, false],
    "id": 1
  }'

getBlockNumber

Returns the block number for the current head.

Parameters

Returns

  • number
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getBlockNumber",
    "params": [],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getBlockNumber",
    "params": [],
    "id": 1
  }'

getCurrentPenalizedSlots

Returns information about the currently penalized slots. This includes slots that lost rewards and that were disabled.

Parameters

Returns

  • blockNumber*: number
  • disabled*: object
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getCurrentPenalizedSlots",
    "params": [],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getCurrentPenalizedSlots",
    "params": [],
    "id": 1
  }'

getEpochNumber

Returns the epoch number for the current head.

Parameters

Returns

  • number
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getEpochNumber",
    "params": [],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getEpochNumber",
    "params": [],
    "id": 1
  }'

getInherentsByBatchNumber

Returns all the inherents (including reward inherents) for the given batch number. Note that this only considers blocks in the main chain.

Parameters

  • batchNumber*: number

Returns

  • array
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getInherentsByBatchNumber",
    "params": [0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getInherentsByBatchNumber",
    "params": [0],
    "id": 1
  }'

getInherentsByBlockNumber

Returns all the inherents (including reward inherents) for the given block number. Note that this only considers blocks in the main chain.

Parameters

  • blockNumber*: number

Returns

  • array
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getInherentsByBlockNumber",
    "params": [0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getInherentsByBlockNumber",
    "params": [0],
    "id": 1
  }'

getLatestBlock

Returns the block at the head of the main chain. It has an option to include the transactions in the block, which defaults to false.

Parameters

  • includeBody*: boolean

Returns

  • hash*: string
  • size*: number
  • batch*: number
  • epoch*: number
  • network*: string
  • version*: number
  • number*: number
  • timestamp*: number
  • parentHash*: string
  • seed*: string
  • extraData*: array
  • stateHash*: string
  • bodyHash: string
  • historyHash*: string
  • transactions: array
  • additionalFields*: object
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getLatestBlock",
    "params": [false],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getLatestBlock",
    "params": [false],
    "id": 1
  }'

getPreviousPenalizedSlots

Returns information about the penalized slots of the previous batch. This includes slots that lost rewards and that were disabled.

Parameters

Returns

  • blockNumber*: number
  • disabled*: object
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getPreviousPenalizedSlots",
    "params": [],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getPreviousPenalizedSlots",
    "params": [],
    "id": 1
  }'

getSlotAt

Returns information about the proposer slot at the given block height and offset. The offset is optional, it will default to getting the offset for the existing block at the given height. We only have this information available for the last 2 batches at most.

Parameters

  • blockNumber*: number
  • offsetOpt*: number

Returns

  • slotNumber*: number
  • validator*: string
  • publicKey*: string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getSlotAt",
    "params": [0, 0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getSlotAt",
    "params": [0, 0],
    "id": 1
  }'

getStakerByAddress

Tries to fetch a staker information given its address.

Parameters

  • address*: string

Returns

  • address*: string
  • balance*: number
  • delegation: string
  • inactiveBalance*: number
  • inactiveFrom: number
  • retiredBalance*: number
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getStakerByAddress",
    "params": ["address"],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getStakerByAddress",
    "params": ["address"],
    "id": 1
  }'

getStakersByValidatorAddress

Fetches all stakers for a given validator. IMPORTANT: This operation iterates over all stakers of the staking contract and thus is extremely computationally expensive.

Parameters

  • address*: string

Returns

  • array
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getStakersByValidatorAddress",
    "params": ["address"],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getStakersByValidatorAddress",
    "params": ["address"],
    "id": 1
  }'

getTransactionByHash

Tries to fetch a transaction (including reward transactions) given its hash.

Parameters

  • hash*: string

Returns

  • transaction*: undefined
  • executionResult*: boolean
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getTransactionByHash",
    "params": ["hash"],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getTransactionByHash",
    "params": ["hash"],
    "id": 1
  }'

getTransactionHashesByAddress

Returns the hashes for the latest transactions for a given address. All the transactions where the given address is listed as a recipient or as a sender are considered. Reward transactions are also returned. It has an option to specify the maximum number of hashes to fetch, it defaults to 500. It has also an option to retrieve transactions before a given transaction hash (exclusive). If this hash is not found or does not belong to this address, it will return an empty list. The transaction hashes are returned in descending order, meaning the latest transaction is the first.

Parameters

  • address*: string
  • max*: number
  • startAt*: string

Returns

  • array
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getTransactionHashesByAddress",
    "params": ["address", 0, "startAt"],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getTransactionHashesByAddress",
    "params": ["address", 0, "startAt"],
    "id": 1
  }'

getTransactionsByAddress

Returns the latest transactions for a given address. All the transactions where the given address is listed as a recipient or as a sender are considered. Reward transactions are also returned. It has an option to specify the maximum number of transactions to fetch, it defaults to 500. It has also an option to retrieve transactions before a given transaction hash (exclusive). If this hash is not found or does not belong to this address, it will return an empty list. The transactions are returned in descending order, meaning the latest transaction is the first.

Parameters

  • address*: string
  • max*: number
  • startAt*: string

Returns

  • array
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getTransactionsByAddress",
    "params": ["address", 0, "startAt"],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getTransactionsByAddress",
    "params": ["address", 0, "startAt"],
    "id": 1
  }'

getTransactionsByBatchNumber

Returns all the transactions (including reward transactions) for the given batch number. Note that this only considers blocks in the main chain.

Parameters

  • batchNumber*: number

Returns

  • array
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getTransactionsByBatchNumber",
    "params": [0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getTransactionsByBatchNumber",
    "params": [0],
    "id": 1
  }'

getTransactionsByBlockNumber

Returns all the transactions (including reward transactions) for the given block number. Note that this only considers blocks in the main chain.

Parameters

  • blockNumber*: number

Returns

  • array
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getTransactionsByBlockNumber",
    "params": [0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getTransactionsByBlockNumber",
    "params": [0],
    "id": 1
  }'

getValidatorByAddress

Tries to fetch a validator information given its address.

Parameters

  • address*: string

Returns

  • address*: string
  • signingKey*: string
  • votingKey*: string
  • rewardAddress*: string
  • signalData: string
  • balance*: number
  • numStakers*: number
  • inactivityFlag: number
  • retired*: boolean
  • jailedFrom: number
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getValidatorByAddress",
    "params": ["address"],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getValidatorByAddress",
    "params": ["address"],
    "id": 1
  }'

getValidators

Fetches all validators in the staking contract. IMPORTANT: This operation iterates over all validators in the staking contract and thus is extremely computationally expensive.

Parameters

Returns

  • array
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getValidators",
    "params": [],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getValidators",
    "params": [],
    "id": 1
  }'

subscribeForHeadBlock

Subscribes to new block events (retrieves the full block).

Parameters

  • includeBody*: boolean

Returns

  • number
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "subscribeForHeadBlock",
    "params": [false],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "subscribeForHeadBlock",
    "params": [false],
    "id": 1
  }'

subscribeForHeadBlockHash

Subscribes to new block events (only retrieves the block hash).

Parameters

Returns

  • number
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "subscribeForHeadBlockHash",
    "params": [],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "subscribeForHeadBlockHash",
    "params": [],
    "id": 1
  }'

subscribeForLogsByAddressesAndTypes

Subscribes to log events related to a given list of addresses and of any of the log types provided. If addresses is empty it does not filter by address. If log_types is empty it won't filter by log types. Thus the behavior is to assume all addresses or log_types are to be provided if the corresponding vec is empty.

Parameters

  • addresses*: string
  • logTypes*: array

Returns

  • number
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "subscribeForLogsByAddressesAndTypes",
    "params": ["addresses", ""],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "subscribeForLogsByAddressesAndTypes",
    "params": ["addresses", ""],
    "id": 1
  }'

subscribeForValidatorElectionByAddress

Subscribes to pre epoch validators events.

Parameters

  • address*: string

Returns

  • number
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "subscribeForValidatorElectionByAddress",
    "params": ["address"],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "subscribeForValidatorElectionByAddress",
    "params": ["address"],
    "id": 1
  }'

Policy

getBatchAt

Returns the batch number at a given block_number (height).

Parameters

  • blockNumber*: number

Returns

  • number
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getBatchAt",
    "params": [0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getBatchAt",
    "params": [0],
    "id": 1
  }'

getBatchIndexAt

Returns the batch index at a given block number. The batch index is the number of a block relative to the batch it is in. For example, the first block of any batch always has an batch index of 0.

Parameters

  • blockNumber*: number

Returns

  • number
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getBatchIndexAt",
    "params": [0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getBatchIndexAt",
    "params": [0],
    "id": 1
  }'

getBlockAfterJail

Returns the first block after the jail period of a given block number has ended.

Parameters

  • blockNumber*: number

Returns

  • number
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getBlockAfterJail",
    "params": [0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getBlockAfterJail",
    "params": [0],
    "id": 1
  }'

getBlockAfterReportingWindow

Returns the first block after the reporting window of a given block number has ended.

Parameters

  • blockNumber*: number

Returns

  • number
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getBlockAfterReportingWindow",
    "params": [0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getBlockAfterReportingWindow",
    "params": [0],
    "id": 1
  }'

getElectionBlockAfter

Returns the number (height) of the next election macro block after a given block number (height).

Parameters

  • blockNumber*: number

Returns

  • number
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getElectionBlockAfter",
    "params": [0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getElectionBlockAfter",
    "params": [0],
    "id": 1
  }'

getElectionBlockBefore

Returns the number block (height) of the preceding election macro block before a given block number (height). If the given block number is an election macro block, it returns the election macro block before it.

Parameters

  • blockNumber*: number

Returns

  • number
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getElectionBlockBefore",
    "params": [0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getElectionBlockBefore",
    "params": [0],
    "id": 1
  }'

getElectionBlockOf

Returns the block number of the election macro block of the given epoch (which is always the last block).

Parameters

  • epoch*: number

Returns

  • number
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getElectionBlockOf",
    "params": [0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getElectionBlockOf",
    "params": [0],
    "id": 1
  }'

getEpochAt

Returns the epoch number at a given block number (height).

Parameters

  • blockNumber*: number

Returns

  • number
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getEpochAt",
    "params": [0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getEpochAt",
    "params": [0],
    "id": 1
  }'

getEpochIndexAt

Returns the epoch index at a given block number. The epoch index is the number of a block relative to the epoch it is in. For example, the first block of any epoch always has an epoch index of 0.

Parameters

  • blockNumber*: number

Returns

  • number
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getEpochIndexAt",
    "params": [0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getEpochIndexAt",
    "params": [0],
    "id": 1
  }'

getFirstBatchOfEpoch

Returns a boolean expressing if the batch at a given block number (height) is the first batch of the epoch.

Parameters

  • blockNumber*: number

Returns

  • boolean
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getFirstBatchOfEpoch",
    "params": [0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getFirstBatchOfEpoch",
    "params": [0],
    "id": 1
  }'

getFirstBlockOf

Returns the block number of the first block of the given epoch (which is always a micro block).

Parameters

  • epoch*: number

Returns

  • number
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getFirstBlockOf",
    "params": [0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getFirstBlockOf",
    "params": [0],
    "id": 1
  }'

getFirstBlockOfBatch

Returns the block number of the first block of the given batch (which is always a micro block).

Parameters

  • batch*: number

Returns

  • number
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getFirstBlockOfBatch",
    "params": [0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getFirstBlockOfBatch",
    "params": [0],
    "id": 1
  }'

getLastElectionBlock

Returns the block number (height) of the last election macro block at a given block number (height). If the given block number is an election macro block, then it returns that block number.

Parameters

  • blockNumber*: number

Returns

  • number
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getLastElectionBlock",
    "params": [0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getLastElectionBlock",
    "params": [0],
    "id": 1
  }'

getLastMacroBlock

Returns block the number (height) of the last macro block at a given block number (height). If the given block number is a macro block, then it returns that block number.

Parameters

  • blockNumber*: number

Returns

  • number
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getLastMacroBlock",
    "params": [0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getLastMacroBlock",
    "params": [0],
    "id": 1
  }'

getMacroBlockAfter

Returns the block number (height) of the next macro block after a given block number (height).

Parameters

  • blockNumber*: number

Returns

  • number
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getMacroBlockAfter",
    "params": [0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getMacroBlockAfter",
    "params": [0],
    "id": 1
  }'

getMacroBlockBefore

Returns the block number (height) of the preceding macro block before a given block number (height). If the given block number is a macro block, it returns the macro block before it.

Parameters

  • blockNumber*: number

Returns

  • number
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getMacroBlockBefore",
    "params": [0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getMacroBlockBefore",
    "params": [0],
    "id": 1
  }'

getMacroBlockOf

Returns the block number of the macro block (checkpoint or election) of the given batch (which is always the last block).

Parameters

  • batch*: number

Returns

  • number
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getMacroBlockOf",
    "params": [0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getMacroBlockOf",
    "params": [0],
    "id": 1
  }'

getPolicyConstants

Returns a bundle of policy constants.

Parameters

Returns

  • stakingContractAddress*: string
  • coinbaseAddress*: string
  • transactionValidityWindow*: number
  • maxSizeMicroBody*: number
  • version*: number
  • slots*: number
  • blocksPerBatch*: number
  • batchesPerEpoch*: number
  • blocksPerEpoch*: number
  • validatorDeposit*: number
  • minimumStake*: number
  • totalSupply*: number
  • blockSeparationTime*: number
  • jailEpochs*: number
  • genesisBlockNumber*: number
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getPolicyConstants",
    "params": [],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getPolicyConstants",
    "params": [],
    "id": 1
  }'

getSupplyAt

Returns the supply at a given time (as Unix time) in Lunas (1 NIM = 100,000 Lunas). It is calculated using the following formula: text supply(t) = total_supply - (total_supply - genesis_supply) * supply_decay^t Where t is the time in milliseconds since the PoS genesis block and genesis_supply is the supply at the genesis of the Nimiq 2.0 chain.

Parameters

  • genesisSupply*: number
  • genesisTime*: number
  • currentTime*: number

Returns

  • number
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getSupplyAt",
    "params": [0, 0, 0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getSupplyAt",
    "params": [0, 0, 0],
    "id": 1
  }'

isElectionBlockAt

Returns a boolean expressing if the block at a given block number (height) is an election macro block.

Parameters

  • blockNumber*: number

Returns

  • boolean
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "isElectionBlockAt",
    "params": [0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "isElectionBlockAt",
    "params": [0],
    "id": 1
  }'

isMacroBlockAt

Returns a boolean expressing if the block at a given block number (height) is a macro block.

Parameters

  • blockNumber*: number

Returns

  • boolean
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "isMacroBlockAt",
    "params": [0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "isMacroBlockAt",
    "params": [0],
    "id": 1
  }'

isMicroBlockAt

Returns a boolean expressing if the block at a given block number (height) is a micro block.

Parameters

  • blockNumber*: number

Returns

  • boolean
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "isMicroBlockAt",
    "params": [0],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "isMicroBlockAt",
    "params": [0],
    "id": 1
  }'

Mempool

getMinFeePerByte

Obtains the minimum fee per byte as per mempool configuration.

Parameters

Returns

  • number
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getMinFeePerByte",
    "params": [],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getMinFeePerByte",
    "params": [],
    "id": 1
  }'

getTransactionFromMempool

Tries to obtain the given transaction (using its hash) from the mempool.

Parameters

  • hash*: string

Returns

  • hash*: string
  • blockNumber: number
  • timestamp: number
  • confirmations: number
  • size*: number
  • relatedAddresses*: object
  • from*: string
  • fromType*: number
  • to*: string
  • toType*: number
  • value*: number
  • fee*: number
  • senderData*: array
  • recipientData*: array
  • flags*: number
  • validityStartHeight*: number
  • proof*: array
  • networkId*: number
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getTransactionFromMempool",
    "params": ["hash"],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getTransactionFromMempool",
    "params": ["hash"],
    "id": 1
  }'

mempool

Obtains the mempool content in fee per byte buckets.

Parameters

Returns

  • 0: number
  • 1: number
  • 2: number
  • 5: number
  • 10: number
  • 20: number
  • 50: number
  • 100: number
  • 200: number
  • 500: number
  • 1000: number
  • 2000: number
  • 5000: number
  • 10000: number
  • total*: number
  • buckets*: array
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "mempool",
    "params": [],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "mempool",
    "params": [],
    "id": 1
  }'

mempoolContent

Obtains the list of transactions that are currently in the mempool.

Parameters

  • includeTransactions*: boolean

Returns

  • array
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "mempoolContent",
    "params": [false],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "mempoolContent",
    "params": [false],
    "id": 1
  }'

pushHighPriorityTransaction

Pushes a raw transaction into the mempool with high priority.

Parameters

  • rawTx*: string

Returns

  • string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "pushHighPriorityTransaction",
    "params": ["rawTx"],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "pushHighPriorityTransaction",
    "params": ["rawTx"],
    "id": 1
  }'

pushTransaction

Pushes a raw transaction into the mempool, it will be assigned a default priority.

Parameters

  • rawTx*: string

Returns

  • string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "pushTransaction",
    "params": ["rawTx"],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "pushTransaction",
    "params": ["rawTx"],
    "id": 1
  }'

Network

getPeerCount

Returns the number of peers.

Parameters

Returns

  • number
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getPeerCount",
    "params": [],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getPeerCount",
    "params": [],
    "id": 1
  }'

getPeerId

Returns the peer ID for our local peer.

Parameters

Returns

  • string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getPeerId",
    "params": [],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getPeerId",
    "params": [],
    "id": 1
  }'

getPeerList

Returns a list with the IDs of all our peers.

Parameters

Returns

  • array
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getPeerList",
    "params": [],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getPeerList",
    "params": [],
    "id": 1
  }'

Zkp component

getZkpState

Returns the current ZKP state (proof with its related block hash and block number).

Parameters

Returns

  • latestBlock*: undefined
  • latestProof: string
JavaScript
const res = await fetch('http://127.0.0.1:8648', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: {
    "jsonrpc": "2.0",
    "method": "getZkpState",
    "params": [],
    "id": 1
  }
});
const data = await res.json();
Shell
curl --request POST --url http://127.0.0.1:8648
  --header 'Content-Type: application/json'
  --data '{
    "jsonrpc": "2.0",
    "method": "getZkpState",
    "params": [],
    "id": 1
  }'