ticket
This module allows you to purchase validator and host tickets that allow you to participate in network consensus operations. Ticket purchasing functions can be accessed from the global variable named
ticket
.ticket.buy(txObject, [signingKey | payloadOnly | [signingKey, payloadOnly]])
Send a transaction to purchase a validator ticket.
- 1.
txObject
-Object
: The transaction objectvalue
-String
: The amount of coins to pay for the ticket.delegate
-String
: Delegate the ticket to another validator by providing their base58 encoded public key.nonce
-Number|String
: The signing account’s next nonce.fee
-String
: The network fee to be paid by the signing account.timestamp
-String
: (optional) The unix timestamp of the transaction.sig
-String
: (optional) The transaction signature. If not provided, the transaction will be signed using thesigningKey
.
- 2.
signingKey
-String
: (optional) The private key to use to sign the transaction. - 3.
payloadOnly
-Boolean
: (optional) When true, the transaction payload is returned instead of being sent to the network.
Object
- The result objecthash
-String
: A 32 bytes transaction hash.
- Create a transaction to purchase a ticket worth 1000 units.
ticket.buy({
value: "1000",
fee: "1"
}, user.getValidator(true).privateKey)
ticket.host.buy(txObject, [signingKey | payloadOnly | [signingKey, payloadOnly]])
Send a transaction to purchase a host ticket.
- 1.
txObject
-Object
: The transaction objectvalue
-String
: The amount of coins to pay for the ticket.delegate
-String
: Delegate the ticket to another host by providing their base58 encoded public key.nonce
-Number|String
: The signing account’s next nonce.fee
-String
: The network fee to be paid by the signing account.timestamp
-String
: (optional) The unix timestamp of the transaction.sig
-String
: (optional) The transaction signature. If not provided, the transaction will be signed using thesigningKey
.
- 2.
signingKey
-String
: (optional) The private key to use to sign the transaction. - 3.
payloadOnly
-Boolean
: (optional) When true, the transaction payload is returned instead of being sent to the network.
Object
- The result objecthash
-String
: A 32 bytes transaction hash.
- Create a transaction to purchase a host ticket for 1000 coins.
ticket.host.buy({
value: "1000",
fee: "1"
}, user.getValidator(true).privateKey)
ticket.list(proposer, [queryopts])
Get validator tickets belonging to a proposer.
- 1.
proposer
-String
: The base58 encoded public key of the proposer. - 2.
queryopts
-Object
: The query optionsexpired
-Boolean
: When true, only decayed tickets will be returned.
Object
- The result objecthash
-String
: A 32 bytes transaction hash.
JavaScript
Output
ticket.list("48J1NrCGHu4D8qkbsGYKRRaVhJgPt3gfFmgwmSeNjMcrsX1fuas")
[
{
"commissionRate": 35,
"delegator": "",
"expireBy": 14040,
"hash": "0x126f53d2f957646b21d8d631198753775f87d6e8ad13cdf17f9338507eb734cc",
"height": 22,
"index": 1,
"matureBy": 25,
"proposerPubKey": [67,155,203,212,6,5,51,24,234,106,169,130,184,236,235,83,105,122,64,91,11,54,228,7,143,69,81,88,62,96,19,203],
"type": 2,
"value": "100"
}
]
ticket.host.list(proposer, [queryopts])
Get validator tickets belonging to a proposer.
- 1.
proposer
-String
: The base58 encoded public key of the proposer. - 2.
queryopts
-Object
: The query options
Object
- The result objecthash
-String
: A 32 bytes transaction hash.
JavaScript
Output
ticket.host.list("48J1NrCGHu4D8qkbsGYKRRaVhJgPt3gfFmgwmSeNjMcrsX1fuas")
[
{
"commissionRate": 35,
"delegator": "",
"expireBy": 14040,
"hash": "0x126f53d2f957646b21d8d631198753775f87d6e8ad13cdf17f9338507eb734cc",
"height": 22,
"index": 1,
"matureBy": 25,
"proposerPubKey": [67,155,203,212,6,5,51,24,234,106,169,130,184,236,235,83,105,122,64,91,11,54,228,7,143,69,81,88,62,96,19,203],
"type": 3,
"value": "100"
}
]
Last modified 2yr ago