github.com/MetalBlockchain/metalgo@v1.11.9/vms/platformvm/service.md (about) 1 --- 2 tags: [P-Chain, Platform Chain, AvalancheGo APIs] 3 description: This page is an overview of the P-Chain API associated with AvalancheGo. 4 sidebar_label: API 5 pagination_label: P-Chain Transaction Format 6 --- 7 8 # Platform Chain API 9 10 This API allows clients to interact with the 11 [P-Chain](/learn/avalanche/avalanche-platform.md#p-chain), which 12 maintains Avalanche’s [validator](/nodes/validate/how-to-stake#validators) set and handles 13 blockchain creation. 14 15 ## Endpoint 16 17 ```sh 18 /ext/bc/P 19 ``` 20 21 ## Format 22 23 This API uses the `json 2.0` RPC format. 24 25 ## Methods 26 27 ### `platform.exportKey` 28 29 :::caution 30 31 Deprecated as of [**v1.9.12**](https://github.com/ava-labs/avalanchego/releases/tag/v1.9.12). 32 33 ::: 34 35 :::warning 36 37 Not recommended for use on Mainnet. See warning notice in [Keystore API](/reference/avalanchego/keystore-api.md). 38 39 ::: 40 41 Get the private key that controls a given address. 42 43 **Signature:** 44 45 ```sh 46 platform.exportKey({ 47 username: string, 48 password: string, 49 address: string 50 }) -> {privateKey: string} 51 ``` 52 53 - `username` is the user that controls `address`. 54 - `password` is `username`‘s password. 55 - `privateKey` is the string representation of the private key that controls `address`. 56 57 **Example Call:** 58 59 ```sh 60 curl -X POST --data '{ 61 "jsonrpc":"2.0", 62 "id" :1, 63 "method" :"platform.exportKey", 64 "params" :{ 65 "username" :"myUsername", 66 "password": "myPassword", 67 "address": "P-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5" 68 } 69 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P 70 ``` 71 72 **Example Response:** 73 74 ```json 75 { 76 "jsonrpc": "2.0", 77 "id": 1, 78 "result": { 79 "privateKey": "PrivateKey-Lf49kAJw3CbaL783vmbeAJvhscJqC7vi5yBYLxw2XfbzNS5RS" 80 } 81 } 82 ``` 83 84 ### `platform.getBalance` 85 86 :::caution 87 88 Deprecated as of [**v1.9.12**](https://github.com/ava-labs/avalanchego/releases/tag/v1.9.12). 89 90 ::: 91 92 Get the balance of AVAX controlled by a given address. 93 94 **Signature:** 95 96 ```sh 97 platform.getBalance({ 98 addresses: []string 99 }) -> { 100 balances: string -> int, 101 unlockeds: string -> int, 102 lockedStakeables: string -> int, 103 lockedNotStakeables: string -> int, 104 utxoIDs: []{ 105 txID: string, 106 outputIndex: int 107 } 108 } 109 ``` 110 111 - `addresses` are the addresses to get the balance of. 112 - `balances` is a map from assetID to the total balance. 113 - `unlockeds` is a map from assetID to the unlocked balance. 114 - `lockedStakeables` is a map from assetID to the locked stakeable balance. 115 - `lockedNotStakeables` is a map from assetID to the locked and not stakeable balance. 116 - `utxoIDs` are the IDs of the UTXOs that reference `address`. 117 118 **Example Call:** 119 120 ```sh 121 curl -X POST --data '{ 122 "jsonrpc":"2.0", 123 "id" : 1, 124 "method" :"platform.getBalance", 125 "params" :{ 126 "addresses":["P-custom18jma8ppw3nhx5r4ap8clazz0dps7rv5u9xde7p"] 127 } 128 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P 129 ``` 130 131 **Example Response:** 132 133 ```json 134 { 135 "jsonrpc": "2.0", 136 "result": { 137 "balance": "30000000000000000", 138 "unlocked": "20000000000000000", 139 "lockedStakeable": "10000000000000000", 140 "lockedNotStakeable": "0", 141 "balances": { 142 "BUuypiq2wyuLMvyhzFXcPyxPMCgSp7eeDohhQRqTChoBjKziC": "30000000000000000" 143 }, 144 "unlockeds": { 145 "BUuypiq2wyuLMvyhzFXcPyxPMCgSp7eeDohhQRqTChoBjKziC": "20000000000000000" 146 }, 147 "lockedStakeables": { 148 "BUuypiq2wyuLMvyhzFXcPyxPMCgSp7eeDohhQRqTChoBjKziC": "10000000000000000" 149 }, 150 "lockedNotStakeables": {}, 151 "utxoIDs": [ 152 { 153 "txID": "11111111111111111111111111111111LpoYY", 154 "outputIndex": 1 155 }, 156 { 157 "txID": "11111111111111111111111111111111LpoYY", 158 "outputIndex": 0 159 } 160 ] 161 }, 162 "id": 1 163 } 164 ``` 165 166 ### `platform.getBlock` 167 168 Get a block by its ID. 169 170 **Signature:** 171 172 ```sh 173 platform.getBlock({ 174 blockID: string 175 encoding: string // optional 176 }) -> { 177 block: string, 178 encoding: string 179 } 180 ``` 181 182 **Request:** 183 184 - `blockID` is the block ID. It should be in cb58 format. 185 - `encoding` is the encoding format to use. Can be either `hex` or `json`. Defaults to `hex`. 186 187 **Response:** 188 189 - `block` is the block encoded to `encoding`. 190 - `encoding` is the `encoding`. 191 192 #### Hex Example 193 194 **Example Call:** 195 196 ```sh 197 curl -X POST --data '{ 198 "jsonrpc": "2.0", 199 "method": "platform.getBlock", 200 "params": { 201 "blockID": "d7WYmb8VeZNHsny3EJCwMm6QA37s1EHwMxw1Y71V3FqPZ5EFG", 202 "encoding": "hex" 203 }, 204 "id": 1 205 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P 206 ``` 207 208 **Example Response:** 209 210 ```json 211 { 212 "jsonrpc": "2.0", 213 "result": { 214 "block": "0x00000000000309473dc99a0851a29174d84e522da8ccb1a56ac23f7b0ba79f80acce34cf576900000000000f4241000000010000001200000001000000000000000000000000000000000000000000000000000000000000000000000000000000011c4c57e1bcb3c567f9f03caa75563502d1a21393173c06d9d79ea247b20e24800000000021e67317cbc4be2aeb00677ad6462778a8f52274b9d605df2591b23027a87dff000000050000000338e0465f0000000100000000000000000427d4b22a2a78bcddd456742caf91b56badbff985ee19aef14573e7343fd6520000000121e67317cbc4be2aeb00677ad6462778a8f52274b9d605df2591b23027a87dff000000070000000338d1041f0000000000000000000000010000000195a4467dd8f939554ea4e6501c08294386938cbf000000010000000900000001c79711c4b48dcde205b63603efef7c61773a0eb47efb503fcebe40d21962b7c25ebd734057400a12cce9cf99aceec8462923d5d91fffe1cb908372281ed738580119286dde", 215 "encoding": "hex" 216 }, 217 "id": 1 218 } 219 ``` 220 221 #### JSON Example 222 223 **Example Call:** 224 225 ```sh 226 curl -X POST --data '{ 227 "jsonrpc": "2.0", 228 "method": "platform.getBlock", 229 "params": { 230 "blockID": "d7WYmb8VeZNHsny3EJCwMm6QA37s1EHwMxw1Y71V3FqPZ5EFG", 231 "encoding": "json" 232 }, 233 "id": 1 234 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P 235 ``` 236 237 **Example Response:** 238 239 ```json 240 { 241 "jsonrpc": "2.0", 242 "result": { 243 "block": { 244 "parentID": "5615di9ytxujackzaXNrVuWQy5y8Yrt8chPCscMr5Ku9YxJ1S", 245 "height": 1000001, 246 "txs": [ 247 { 248 "unsignedTx": { 249 "inputs": { 250 "networkID": 1, 251 "blockchainID": "11111111111111111111111111111111LpoYY", 252 "outputs": [], 253 "inputs": [ 254 { 255 "txID": "DTqiagiMFdqbNQ62V2Gt1GddTVLkKUk2caGr4pyza9hTtsfta", 256 "outputIndex": 0, 257 "assetID": "FvwEAhmxKfeiG8SnEvq42hc6whRyY3EFYAvebMqDNDGCgxN5Z", 258 "fxID": "spdxUxVJQbX85MGxMHbKw1sHxMnSqJ3QBzDyDYEP3h6TLuxqQ", 259 "input": { 260 "amount": 13839124063, 261 "signatureIndices": [0] 262 } 263 } 264 ], 265 "memo": "0x" 266 }, 267 "destinationChain": "2q9e4r6Mu3U68nU1fYjgbR6JvwrRx36CohpAX5UQxse55x1Q5", 268 "exportedOutputs": [ 269 { 270 "assetID": "FvwEAhmxKfeiG8SnEvq42hc6whRyY3EFYAvebMqDNDGCgxN5Z", 271 "fxID": "spdxUxVJQbX85MGxMHbKw1sHxMnSqJ3QBzDyDYEP3h6TLuxqQ", 272 "output": { 273 "addresses": [ 274 "P-avax1jkjyvlwclyu42n4yuegpczpfgwrf8r9lyj0d3c" 275 ], 276 "amount": 13838124063, 277 "locktime": 0, 278 "threshold": 1 279 } 280 } 281 ] 282 }, 283 "credentials": [ 284 { 285 "signatures": [ 286 "0xc79711c4b48dcde205b63603efef7c61773a0eb47efb503fcebe40d21962b7c25ebd734057400a12cce9cf99aceec8462923d5d91fffe1cb908372281ed7385801" 287 ] 288 } 289 ] 290 } 291 ] 292 }, 293 "encoding": "json" 294 }, 295 "id": 1 296 } 297 ``` 298 299 ### `platform.getBlockByHeight` 300 301 Get a block by its height. 302 303 **Signature:** 304 305 ```sh 306 platform.getBlockByHeight({ 307 height: int 308 encoding: string // optional 309 }) -> { 310 block: string, 311 encoding: string 312 } 313 ``` 314 315 **Request:** 316 317 - `height` is the block height. 318 - `encoding` is the encoding format to use. Can be either `hex` or `json`. Defaults to `hex`. 319 320 **Response:** 321 322 - `block` is the block encoded to `encoding`. 323 - `encoding` is the `encoding`. 324 325 #### Hex Example 326 327 **Example Call:** 328 329 ```sh 330 curl -X POST --data '{ 331 "jsonrpc": "2.0", 332 "method": "platform.getBlockByHeight", 333 "params": { 334 "height": 1000001, 335 "encoding": "hex" 336 }, 337 "id": 1 338 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P 339 ``` 340 341 **Example Response:** 342 343 ```json 344 { 345 "jsonrpc": "2.0", 346 "result": { 347 "block": "0x00000000000309473dc99a0851a29174d84e522da8ccb1a56ac23f7b0ba79f80acce34cf576900000000000f4241000000010000001200000001000000000000000000000000000000000000000000000000000000000000000000000000000000011c4c57e1bcb3c567f9f03caa75563502d1a21393173c06d9d79ea247b20e24800000000021e67317cbc4be2aeb00677ad6462778a8f52274b9d605df2591b23027a87dff000000050000000338e0465f0000000100000000000000000427d4b22a2a78bcddd456742caf91b56badbff985ee19aef14573e7343fd6520000000121e67317cbc4be2aeb00677ad6462778a8f52274b9d605df2591b23027a87dff000000070000000338d1041f0000000000000000000000010000000195a4467dd8f939554ea4e6501c08294386938cbf000000010000000900000001c79711c4b48dcde205b63603efef7c61773a0eb47efb503fcebe40d21962b7c25ebd734057400a12cce9cf99aceec8462923d5d91fffe1cb908372281ed738580119286dde", 348 "encoding": "hex" 349 }, 350 "id": 1 351 } 352 ``` 353 354 #### JSON Example 355 356 **Example Call:** 357 358 ```sh 359 curl -X POST --data '{ 360 "jsonrpc": "2.0", 361 "method": "platform.getBlockByHeight", 362 "params": { 363 "height": 1000001, 364 "encoding": "json" 365 }, 366 "id": 1 367 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P 368 ``` 369 370 **Example Response:** 371 372 ```json 373 { 374 "jsonrpc": "2.0", 375 "result": { 376 "block": { 377 "parentID": "5615di9ytxujackzaXNrVuWQy5y8Yrt8chPCscMr5Ku9YxJ1S", 378 "height": 1000001, 379 "txs": [ 380 { 381 "unsignedTx": { 382 "inputs": { 383 "networkID": 1, 384 "blockchainID": "11111111111111111111111111111111LpoYY", 385 "outputs": [], 386 "inputs": [ 387 { 388 "txID": "DTqiagiMFdqbNQ62V2Gt1GddTVLkKUk2caGr4pyza9hTtsfta", 389 "outputIndex": 0, 390 "assetID": "FvwEAhmxKfeiG8SnEvq42hc6whRyY3EFYAvebMqDNDGCgxN5Z", 391 "fxID": "spdxUxVJQbX85MGxMHbKw1sHxMnSqJ3QBzDyDYEP3h6TLuxqQ", 392 "input": { 393 "amount": 13839124063, 394 "signatureIndices": [0] 395 } 396 } 397 ], 398 "memo": "0x" 399 }, 400 "destinationChain": "2q9e4r6Mu3U68nU1fYjgbR6JvwrRx36CohpAX5UQxse55x1Q5", 401 "exportedOutputs": [ 402 { 403 "assetID": "FvwEAhmxKfeiG8SnEvq42hc6whRyY3EFYAvebMqDNDGCgxN5Z", 404 "fxID": "spdxUxVJQbX85MGxMHbKw1sHxMnSqJ3QBzDyDYEP3h6TLuxqQ", 405 "output": { 406 "addresses": [ 407 "P-avax1jkjyvlwclyu42n4yuegpczpfgwrf8r9lyj0d3c" 408 ], 409 "amount": 13838124063, 410 "locktime": 0, 411 "threshold": 1 412 } 413 } 414 ] 415 }, 416 "credentials": [ 417 { 418 "signatures": [ 419 "0xc79711c4b48dcde205b63603efef7c61773a0eb47efb503fcebe40d21962b7c25ebd734057400a12cce9cf99aceec8462923d5d91fffe1cb908372281ed7385801" 420 ] 421 } 422 ] 423 } 424 ] 425 }, 426 "encoding": "json" 427 }, 428 "id": 1 429 } 430 ``` 431 432 ### `platform.getBlockchains` 433 434 :::caution 435 436 Deprecated as of [**v1.9.12**](https://github.com/ava-labs/avalanchego/releases/tag/v1.9.12). 437 438 ::: 439 440 Get all the blockchains that exist (excluding the P-Chain). 441 442 **Signature:** 443 444 ```sh 445 platform.getBlockchains() -> 446 { 447 blockchains: []{ 448 id: string, 449 name:string, 450 subnetID: string, 451 vmID: string 452 } 453 } 454 ``` 455 456 - `blockchains` is all of the blockchains that exists on the Avalanche network. 457 - `name` is the human-readable name of this blockchain. 458 - `id` is the blockchain’s ID. 459 - `subnetID` is the ID of the Subnet that validates this blockchain. 460 - `vmID` is the ID of the Virtual Machine the blockchain runs. 461 462 **Example Call:** 463 464 ```sh 465 curl -X POST --data '{ 466 "jsonrpc": "2.0", 467 "method": "platform.getBlockchains", 468 "params": {}, 469 "id": 1 470 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P 471 ``` 472 473 **Example Response:** 474 475 ```json 476 { 477 "jsonrpc": "2.0", 478 "result": { 479 "blockchains": [ 480 { 481 "id": "2oYMBNV4eNHyqk2fjjV5nVQLDbtmNJzq5s3qs3Lo6ftnC6FByM", 482 "name": "X-Chain", 483 "subnetID": "11111111111111111111111111111111LpoYY", 484 "vmID": "jvYyfQTxGMJLuGWa55kdP2p2zSUYsQ5Raupu4TW34ZAUBAbtq" 485 }, 486 { 487 "id": "2q9e4r6Mu3U68nU1fYjgbR6JvwrRx36CohpAX5UQxse55x1Q5", 488 "name": "C-Chain", 489 "subnetID": "11111111111111111111111111111111LpoYY", 490 "vmID": "mgj786NP7uDwBCcq6YwThhaN8FLyybkCa4zBWTQbNgmK6k9A6" 491 }, 492 { 493 "id": "CqhF97NNugqYLiGaQJ2xckfmkEr8uNeGG5TQbyGcgnZ5ahQwa", 494 "name": "Simple DAG Payments", 495 "subnetID": "11111111111111111111111111111111LpoYY", 496 "vmID": "sqjdyTKUSrQs1YmKDTUbdUhdstSdtRTGRbUn8sqK8B6pkZkz1" 497 }, 498 { 499 "id": "VcqKNBJsYanhVFxGyQE5CyNVYxL3ZFD7cnKptKWeVikJKQkjv", 500 "name": "Simple Chain Payments", 501 "subnetID": "11111111111111111111111111111111LpoYY", 502 "vmID": "sqjchUjzDqDfBPGjfQq2tXW1UCwZTyvzAWHsNzF2cb1eVHt6w" 503 }, 504 { 505 "id": "2SMYrx4Dj6QqCEA3WjnUTYEFSnpqVTwyV3GPNgQqQZbBbFgoJX", 506 "name": "Simple Timestamp Server", 507 "subnetID": "11111111111111111111111111111111LpoYY", 508 "vmID": "tGas3T58KzdjLHhBDMnH2TvrddhqTji5iZAMZ3RXs2NLpSnhH" 509 }, 510 { 511 "id": "KDYHHKjM4yTJTT8H8qPs5KXzE6gQH5TZrmP1qVr1P6qECj3XN", 512 "name": "My new timestamp", 513 "subnetID": "2bRCr6B4MiEfSjidDwxDpdCyviwnfUVqB2HGwhm947w9YYqb7r", 514 "vmID": "tGas3T58KzdjLHhBDMnH2TvrddhqTji5iZAMZ3RXs2NLpSnhH" 515 }, 516 { 517 "id": "2TtHFqEAAJ6b33dromYMqfgavGPF3iCpdG3hwNMiart2aB5QHi", 518 "name": "My new AVM", 519 "subnetID": "2bRCr6B4MiEfSjidDwxDpdCyviwnfUVqB2HGwhm947w9YYqb7r", 520 "vmID": "jvYyfQTxGMJLuGWa55kdP2p2zSUYsQ5Raupu4TW34ZAUBAbtq" 521 } 522 ] 523 }, 524 "id": 1 525 } 526 ``` 527 528 ### `platform.getBlockchainStatus` 529 530 Get the status of a blockchain. 531 532 **Signature:** 533 534 ```sh 535 platform.getBlockchainStatus( 536 { 537 blockchainID: string 538 } 539 ) -> {status: string} 540 ``` 541 542 `status` is one of: 543 544 - `Validating`: The blockchain is being validated by this node. 545 - `Created`: The blockchain exists but isn’t being validated by this node. 546 - `Preferred`: The blockchain was proposed to be created and is likely to be created but the 547 transaction isn’t yet accepted. 548 - `Syncing`: This node is participating in this blockchain as a non-validating node. 549 - `Unknown`: The blockchain either wasn’t proposed or the proposal to create it isn’t preferred. The 550 proposal may be resubmitted. 551 552 **Example Call:** 553 554 ```sh 555 curl -X POST --data '{ 556 "jsonrpc": "2.0", 557 "method": "platform.getBlockchainStatus", 558 "params":{ 559 "blockchainID":"2NbS4dwGaf2p1MaXb65PrkZdXRwmSX4ZzGnUu7jm3aykgThuZE" 560 }, 561 "id": 1 562 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P 563 ``` 564 565 **Example Response:** 566 567 ```json 568 { 569 "jsonrpc": "2.0", 570 "result": { 571 "status": "Created" 572 }, 573 "id": 1 574 } 575 ``` 576 577 ### `platform.getCurrentSupply` 578 579 Returns an upper bound on amount of tokens that exist that can stake the requested Subnet. This is 580 an upper bound because it does not account for burnt tokens, including transaction fees. 581 582 **Signature:** 583 584 ```sh 585 platform.getCurrentSupply({ 586 subnetID: string // optional 587 }) -> {supply: int} 588 ``` 589 590 - `supply` is an upper bound on the number of tokens that exist. 591 592 **Example Call:** 593 594 ```sh 595 curl -X POST --data '{ 596 "jsonrpc": "2.0", 597 "method": "platform.getCurrentSupply", 598 "params": { 599 "subnetID": "11111111111111111111111111111111LpoYY" 600 }, 601 "id": 1 602 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P 603 ``` 604 605 **Example Response:** 606 607 ```json 608 { 609 "jsonrpc": "2.0", 610 "result": { 611 "supply": "365865167637779183" 612 }, 613 "id": 1 614 } 615 ``` 616 617 The response in this example indicates that AVAX’s supply is at most 365.865 million. 618 619 ### `platform.getCurrentValidators` 620 621 List the current validators of the given Subnet. 622 623 **Signature:** 624 625 ```sh 626 platform.getCurrentValidators({ 627 subnetID: string, // optional 628 nodeIDs: string[], // optional 629 }) -> { 630 validators: []{ 631 txID: string, 632 startTime: string, 633 endTime: string, 634 stakeAmount: string, 635 nodeID: string, 636 weight: string, 637 validationRewardOwner: { 638 locktime: string, 639 threshold: string, 640 addresses: string[] 641 }, 642 delegationRewardOwner: { 643 locktime: string, 644 threshold: string, 645 addresses: string[] 646 }, 647 potentialReward: string, 648 delegationFee: string, 649 uptime: string, 650 connected: bool, 651 signer: { 652 publicKey: string, 653 proofOfPosession: string 654 }, 655 delegatorCount: string, 656 delegatorWeight: string, 657 delegators: []{ 658 txID: string, 659 startTime: string, 660 endTime: string, 661 stakeAmount: string, 662 nodeID: string, 663 rewardOwner: { 664 locktime: string, 665 threshold: string, 666 addresses: string[] 667 }, 668 potentialReward: string, 669 } 670 } 671 } 672 ``` 673 674 - `subnetID` is the Subnet whose current validators are returned. If omitted, returns the current 675 validators of the Primary Network. 676 - `nodeIDs` is a list of the NodeIDs of current validators to request. If omitted, all current 677 validators are returned. If a specified NodeID is not in the set of current validators, it will 678 not be included in the response. 679 - `validators`: 680 - `txID` is the validator transaction. 681 - `startTime` is the Unix time when the validator starts validating the Subnet. 682 - `endTime` is the Unix time when the validator stops validating the Subnet. 683 - `stakeAmount` is the amount of tokens this validator staked. Omitted if `subnetID` is not a PoS 684 Subnet. 685 - `nodeID` is the validator’s node ID. 686 - `weight` is the validator’s weight when sampling validators. Omitted if `subnetID` is a PoS 687 Subnet. 688 - `validationRewardOwner` is an `OutputOwners` output which includes `locktime`, `threshold` and 689 array of `addresses`. Specifies the owner of the potential reward earned from staking. Omitted 690 if `subnetID` is not a PoS Subnet. 691 - `delegationRewardOwner` is an `OutputOwners` output which includes `locktime`, `threshold` and 692 array of `addresses`. Specifies the owner of the potential reward earned from delegations. 693 Omitted if `subnetID` is not a PoS Subnet. 694 - `potentialReward` is the potential reward earned from staking. Omitted if `subnetID` is not a 695 PoS Subnet. 696 - `delegationFeeRate` is the percent fee this validator charges when others delegate stake to 697 them. Omitted if `subnetID` is not a PoS Subnet. 698 - `uptime` is the % of time the queried node has reported the peer as online and validating the 699 Subnet. Omitted if `subnetID` is not a PoS Subnet. 700 - `connected` is if the node is connected and tracks the Subnet. 701 - `signer` is the node's BLS public key and proof of possession. Omitted if the validator doesn't 702 have a BLS public key. 703 - `delegatorCount` is the number of delegators on this validator. 704 Omitted if `subnetID` is not a PoS Subnet. 705 - `delegatorWeight` is total weight of delegators on this validator. 706 Omitted if `subnetID` is not a PoS Subnet. 707 - `delegators` is the list of delegators to this validator. 708 Omitted if `subnetID` is not a PoS Subnet. 709 Omitted unless `nodeIDs` specifies a single NodeID. 710 - `txID` is the delegator transaction. 711 - `startTime` is the Unix time when the delegator started. 712 - `endTime` is the Unix time when the delegator stops. 713 - `stakeAmount` is the amount of nAVAX this delegator staked. 714 - `nodeID` is the validating node’s node ID. 715 - `rewardOwner` is an `OutputOwners` output which includes `locktime`, `threshold` and array of 716 `addresses`. 717 - `potentialReward` is the potential reward earned from staking 718 719 **Example Call:** 720 721 ```sh 722 curl -X POST --data '{ 723 "jsonrpc": "2.0", 724 "method": "platform.getCurrentValidators", 725 "params": { 726 "nodeIDs": ["NodeID-5mb46qkSBj81k9g9e4VFjGGSbaaSLFRzD"] 727 }, 728 "id": 1 729 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P 730 ``` 731 732 **Example Response:** 733 734 ```json 735 { 736 "jsonrpc": "2.0", 737 "result": { 738 "validators": [ 739 { 740 "txID": "2NNkpYTGfTFLSGXJcHtVv6drwVU2cczhmjK2uhvwDyxwsjzZMm", 741 "startTime": "1600368632", 742 "endTime": "1602960455", 743 "stakeAmount": "2000000000000", 744 "nodeID": "NodeID-5mb46qkSBj81k9g9e4VFjGGSbaaSLFRzD", 745 "validationRewardOwner": { 746 "locktime": "0", 747 "threshold": "1", 748 "addresses": ["P-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5"] 749 }, 750 "delegationRewardOwner": { 751 "locktime": "0", 752 "threshold": "1", 753 "addresses": ["P-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5"] 754 }, 755 "potentialReward": "117431493426", 756 "delegationFee": "10.0000", 757 "uptime": "0.0000", 758 "connected": false, 759 "delegatorCount": "1", 760 "delegatorWeight": "25000000000", 761 "delegators": [ 762 { 763 "txID": "Bbai8nzGVcyn2VmeYcbS74zfjJLjDacGNVuzuvAQkHn1uWfoV", 764 "startTime": "1600368523", 765 "endTime": "1602960342", 766 "stakeAmount": "25000000000", 767 "nodeID": "NodeID-5mb46qkSBj81k9g9e4VFjGGSbaaSLFRzD", 768 "rewardOwner": { 769 "locktime": "0", 770 "threshold": "1", 771 "addresses": ["P-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5"] 772 }, 773 "potentialReward": "11743144774" 774 } 775 ] 776 } 777 ] 778 }, 779 "id": 1 780 } 781 ``` 782 783 ### `platform.getHeight` 784 785 Returns the height of the last accepted block. 786 787 **Signature:** 788 789 ```sh 790 platform.getHeight() -> 791 { 792 height: int, 793 } 794 ``` 795 796 **Example Call:** 797 798 ```sh 799 curl -X POST --data '{ 800 "jsonrpc": "2.0", 801 "method": "platform.getHeight", 802 "params": {}, 803 "id": 1 804 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P 805 ``` 806 807 **Example Response:** 808 809 ```json 810 { 811 "jsonrpc": "2.0", 812 "result": { 813 "height": "56" 814 }, 815 "id": 1 816 } 817 ``` 818 819 ### `platform.getMaxStakeAmount` 820 821 :::caution 822 823 Deprecated as of [**v1.9.12**](https://github.com/ava-labs/avalanchego/releases/tag/v1.9.12). 824 825 ::: 826 827 Returns the maximum amount of nAVAX staking to the named node during a particular time period. 828 829 **Signature:** 830 831 ```sh 832 platform.getMaxStakeAmount( 833 { 834 subnetID: string, 835 nodeID: string, 836 startTime: int, 837 endTime: int 838 } 839 ) -> 840 { 841 amount: uint64 842 } 843 ``` 844 845 - `subnetID` is a Buffer or cb58 string representing Subnet 846 - `nodeID` is a string representing ID of the node whose stake amount is required during the given 847 duration 848 - `startTime` is a big number denoting start time of the duration during which stake amount of the 849 node is required. 850 - `endTime` is a big number denoting end time of the duration during which stake amount of the node 851 is required. 852 853 **Example Call:** 854 855 ```sh 856 curl -X POST --data '{ 857 "jsonrpc": "2.0", 858 "method": "platform.getMaxStakeAmount", 859 "params": { 860 "subnetID":"11111111111111111111111111111111LpoYY", 861 "nodeID":"NodeID-7Xhw2mDxuDS44j42TCB6U5579esbSt3Lg", 862 "startTime": 1644240334, 863 "endTime": 1644240634 864 }, 865 "id": 1 866 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P 867 ``` 868 869 **Example Response:** 870 871 ```json 872 { 873 "jsonrpc": "2.0", 874 "result": { 875 "amount": "2000000000000000" 876 }, 877 "id": 1 878 } 879 ``` 880 881 ### `platform.getMinStake` 882 883 Get the minimum amount of tokens required to validate the requested Subnet and the minimum amount of 884 tokens that can be delegated. 885 886 **Signature:** 887 888 ```sh 889 platform.getMinStake({ 890 subnetID: string // optional 891 }) -> 892 { 893 minValidatorStake : uint64, 894 minDelegatorStake : uint64 895 } 896 ``` 897 898 **Example Call:** 899 900 ```sh 901 curl -X POST --data '{ 902 "jsonrpc":"2.0", 903 "id" :1, 904 "method" :"platform.getMinStake", 905 "params": { 906 "subnetID":"11111111111111111111111111111111LpoYY" 907 }, 908 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P 909 ``` 910 911 **Example Response:** 912 913 ```json 914 { 915 "jsonrpc": "2.0", 916 "result": { 917 "minValidatorStake": "2000000000000", 918 "minDelegatorStake": "25000000000" 919 }, 920 "id": 1 921 } 922 ``` 923 924 ### `platform.getPendingValidators` 925 926 List the validators in the pending validator set of the specified Subnet. Each validator is not 927 currently validating the Subnet but will in the future. 928 929 **Signature:** 930 931 ```sh 932 platform.getPendingValidators({ 933 subnetID: string, // optional 934 nodeIDs: string[], // optional 935 }) -> { 936 validators: []{ 937 txID: string, 938 startTime: string, 939 endTime: string, 940 stakeAmount: string, 941 nodeID: string, 942 delegationFee: string, 943 connected: bool, 944 signer: { 945 publicKey: string, 946 proofOfPosession: string 947 }, 948 weight: string, 949 }, 950 delegators: []{ 951 txID: string, 952 startTime: string, 953 endTime: string, 954 stakeAmount: string, 955 nodeID: string 956 } 957 } 958 ``` 959 960 - `subnetID` is the Subnet whose current validators are returned. If omitted, returns the current 961 validators of the Primary Network. 962 - `nodeIDs` is a list of the NodeIDs of pending validators to request. If omitted, all pending 963 validators are returned. If a specified NodeID is not in the set of pending validators, it will 964 not be included in the response. 965 - `validators`: 966 - `txID` is the validator transaction. 967 - `startTime` is the Unix time when the validator starts validating the Subnet. 968 - `endTime` is the Unix time when the validator stops validating the Subnet. 969 - `stakeAmount` is the amount of tokens this validator staked. Omitted if `subnetID` is not a PoS 970 Subnet. 971 - `nodeID` is the validator’s node ID. 972 - `connected` if the node is connected and tracks the Subnet. 973 - `signer` is the node's BLS public key and proof of possession. Omitted if the validator doesn't 974 have a BLS public key. 975 - `weight` is the validator’s weight when sampling validators. Omitted if `subnetID` is a PoS 976 Subnet. 977 - `delegators`: 978 - `txID` is the delegator transaction. 979 - `startTime` is the Unix time when the delegator starts. 980 - `endTime` is the Unix time when the delegator stops. 981 - `stakeAmount` is the amount of tokens this delegator staked. 982 - `nodeID` is the validating node’s node ID. 983 984 **Example Call:** 985 986 ```sh 987 curl -X POST --data '{ 988 "jsonrpc": "2.0", 989 "method": "platform.getPendingValidators", 990 "params": {}, 991 "id": 1 992 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P 993 ``` 994 995 **Example Response:** 996 997 ```json 998 { 999 "jsonrpc": "2.0", 1000 "result": { 1001 "validators": [ 1002 { 1003 "txID": "2NNkpYTGfTFLSGXJcHtVv6drwVU2cczhmjK2uhvwDyxwsjzZMm", 1004 "startTime": "1600368632", 1005 "endTime": "1602960455", 1006 "stakeAmount": "200000000000", 1007 "nodeID": "NodeID-5mb46qkSBj81k9g9e4VFjGGSbaaSLFRzD", 1008 "delegationFee": "10.0000", 1009 "connected": false 1010 } 1011 ], 1012 "delegators": [ 1013 { 1014 "txID": "Bbai8nzGVcyn2VmeYcbS74zfjJLjDacGNVuzuvAQkHn1uWfoV", 1015 "startTime": "1600368523", 1016 "endTime": "1602960342", 1017 "stakeAmount": "20000000000", 1018 "nodeID": "NodeID-7Xhw2mDxuDS44j42TCB6U5579esbSt3Lg" 1019 } 1020 ] 1021 }, 1022 "id": 1 1023 } 1024 ``` 1025 1026 ### `platform.getRewardUTXOs` 1027 1028 :::caution 1029 1030 Deprecated as of [**v1.9.12**](https://github.com/ava-labs/avalanchego/releases/tag/v1.9.12). 1031 1032 ::: 1033 1034 Returns the UTXOs that were rewarded after the provided transaction's staking or delegation period 1035 ended. 1036 1037 **Signature:** 1038 1039 ```sh 1040 platform.getRewardUTXOs({ 1041 txID: string, 1042 encoding: string // optional 1043 }) -> { 1044 numFetched: integer, 1045 utxos: []string, 1046 encoding: string 1047 } 1048 ``` 1049 1050 - `txID` is the ID of the staking or delegating transaction 1051 - `numFetched` is the number of returned UTXOs 1052 - `utxos` is an array of encoded reward UTXOs 1053 - `encoding` specifies the format for the returned UTXOs. Can only be `hex` when a value is 1054 provided. 1055 1056 **Example Call:** 1057 1058 ```sh 1059 curl -X POST --data '{ 1060 "jsonrpc": "2.0", 1061 "method": "platform.getRewardUTXOs", 1062 "params": { 1063 "txID": "2nmH8LithVbdjaXsxVQCQfXtzN9hBbmebrsaEYnLM9T32Uy2Y5" 1064 }, 1065 "id": 1 1066 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P 1067 ``` 1068 1069 **Example Response:** 1070 1071 ```json 1072 { 1073 "jsonrpc": "2.0", 1074 "result": { 1075 "numFetched": "2", 1076 "utxos": [ 1077 "0x0000a195046108a85e60f7a864bb567745a37f50c6af282103e47cc62f036cee404700000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f216c1f01765", 1078 "0x0000ae8b1b94444eed8de9a81b1222f00f1b4133330add23d8ac288bffa98b85271100000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f216473d042a" 1079 ], 1080 "encoding": "hex" 1081 }, 1082 "id": 1 1083 } 1084 ``` 1085 1086 ### `platform.getStake` 1087 1088 :::caution 1089 1090 Deprecated as of [**v1.9.12**](https://github.com/ava-labs/avalanchego/releases/tag/v1.9.12). 1091 1092 ::: 1093 1094 Get the amount of nAVAX staked by a set of addresses. The amount returned does not include staking 1095 rewards. 1096 1097 **Signature:** 1098 1099 ```sh 1100 platform.getStake({ 1101 addresses: []string, 1102 validatorsOnly: true or false 1103 }) -> 1104 { 1105 stakeds: string -> int, 1106 stakedOutputs: []string, 1107 encoding: string 1108 } 1109 ``` 1110 1111 - `addresses` are the addresses to get information about. 1112 - `validatorsOnly` can be either `true` or `false`. If `true`, will skip checking delegators for stake. 1113 - `stakeds` is a map from assetID to the amount staked by addresses provided. 1114 - `stakedOutputs` are the string representation of staked outputs. 1115 - `encoding` specifies the format for the returned outputs. 1116 1117 **Example Call:** 1118 1119 ```sh 1120 curl -X POST --data '{ 1121 "jsonrpc": "2.0", 1122 "method": "platform.getStake", 1123 "params": { 1124 "addresses": [ 1125 "P-avax1pmgmagjcljjzuz2ve339dx82khm7q8getlegte" 1126 ], 1127 "validatorsOnly": true 1128 }, 1129 "id": 1 1130 } 1131 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P 1132 ``` 1133 1134 **Example Response:** 1135 1136 ```json 1137 { 1138 "jsonrpc": "2.0", 1139 "result": { 1140 "staked": "6500000000000", 1141 "stakeds": { 1142 "FvwEAhmxKfeiG8SnEvq42hc6whRyY3EFYAvebMqDNDGCgxN5Z": "6500000000000" 1143 }, 1144 "stakedOutputs": [ 1145 "0x000021e67317cbc4be2aeb00677ad6462778a8f52274b9d605df2591b23027a87dff00000007000005e96630e800000000000000000000000001000000011f1c933f38da6ba0ba46f8c1b0a7040a9a991a80dd338ed1" 1146 ], 1147 "encoding": "hex" 1148 }, 1149 "id": 1 1150 } 1151 ``` 1152 1153 ### `platform.getStakingAssetID` 1154 1155 Retrieve an assetID for a Subnet’s staking asset. 1156 1157 **Signature:** 1158 1159 ```sh 1160 platform.getStakingAssetID({ 1161 subnetID: string // optional 1162 }) -> { 1163 assetID: string 1164 } 1165 ``` 1166 1167 - `subnetID` is the Subnet whose assetID is requested. 1168 - `assetID` is the assetID for a Subnet’s staking asset. 1169 1170 **Example Call:** 1171 1172 ```sh 1173 curl -X POST --data '{ 1174 "jsonrpc": "2.0", 1175 "method": "platform.getStakingAssetID", 1176 "params": { 1177 "subnetID": "11111111111111111111111111111111LpoYY" 1178 }, 1179 "id": 1 1180 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P 1181 ``` 1182 1183 **Example Response:** 1184 1185 ```json 1186 { 1187 "jsonrpc": "2.0", 1188 "result": { 1189 "assetID": "2fombhL7aGPwj3KH4bfrmJwW6PVnMobf9Y2fn9GwxiAAJyFDbe" 1190 }, 1191 "id": 1 1192 } 1193 ``` 1194 1195 :::note 1196 1197 The AssetID for AVAX differs depending on the network you are on. 1198 1199 Mainnet: FvwEAhmxKfeiG8SnEvq42hc6whRyY3EFYAvebMqDNDGCgxN5Z 1200 1201 Testnet: U8iRqJoiJm8xZHAacmvYyZVwqQx6uDNtQeP3CQ6fcgQk3JqnK 1202 1203 ::: 1204 1205 ### `platform.getSubnets` 1206 1207 :::caution 1208 1209 Deprecated as of [**v1.9.12**](https://github.com/ava-labs/avalanchego/releases/tag/v1.9.12). 1210 1211 ::: 1212 1213 Get info about the Subnets. 1214 1215 **Signature:** 1216 1217 ```sh 1218 platform.getSubnets({ 1219 ids: []string 1220 }) -> 1221 { 1222 subnets: []{ 1223 id: string, 1224 controlKeys: []string, 1225 threshold: string 1226 } 1227 } 1228 ``` 1229 1230 - `ids` are the IDs of the Subnets to get information about. If omitted, gets information about all 1231 Subnets. 1232 - `id` is the Subnet’s ID. 1233 - `threshold` signatures from addresses in `controlKeys` are needed to add a validator to the 1234 Subnet. If the Subnet is a PoS Subnet, then `threshold` will be `0` and `controlKeys` will be 1235 empty. 1236 1237 See [here](/nodes/validate/add-a-validator.md) for information on adding a validator to a 1238 Subnet. 1239 1240 **Example Call:** 1241 1242 ```sh 1243 curl -X POST --data '{ 1244 "jsonrpc": "2.0", 1245 "method": "platform.getSubnets", 1246 "params": {"ids":["hW8Ma7dLMA7o4xmJf3AXBbo17bXzE7xnThUd3ypM4VAWo1sNJ"]}, 1247 "id": 1 1248 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P 1249 ``` 1250 1251 **Example Response:** 1252 1253 ```json 1254 { 1255 "jsonrpc": "2.0", 1256 "result": { 1257 "subnets": [ 1258 { 1259 "id": "hW8Ma7dLMA7o4xmJf3AXBbo17bXzE7xnThUd3ypM4VAWo1sNJ", 1260 "controlKeys": [ 1261 "KNjXsaA1sZsaKCD1cd85YXauDuxshTes2", 1262 "Aiz4eEt5xv9t4NCnAWaQJFNz5ABqLtJkR" 1263 ], 1264 "threshold": "2" 1265 } 1266 ] 1267 }, 1268 "id": 1 1269 } 1270 ``` 1271 1272 ### `platform.getTimestamp` 1273 1274 Get the current P-Chain timestamp. 1275 1276 **Signature:** 1277 1278 ```sh 1279 platform.getTimestamp() -> {time: string} 1280 ``` 1281 1282 **Example Call:** 1283 1284 ```sh 1285 curl -X POST --data '{ 1286 "jsonrpc": "2.0", 1287 "method": "platform.getTimestamp", 1288 "params": {}, 1289 "id": 1 1290 } 1291 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P 1292 ``` 1293 1294 **Example Response:** 1295 1296 ```json 1297 { 1298 "jsonrpc": "2.0", 1299 "result": { 1300 "timestamp": "2021-09-07T00:00:00-04:00" 1301 }, 1302 "id": 1 1303 } 1304 ``` 1305 1306 ### `platform.getTotalStake` 1307 1308 Get the total amount of tokens staked on the requested Subnet. 1309 1310 **Signature:** 1311 1312 ```sh 1313 platform.getTotalStake({ 1314 subnetID: string 1315 }) -> { 1316 stake: int 1317 weight: int 1318 } 1319 ``` 1320 1321 #### Primary Network Example 1322 1323 **Example Call:** 1324 1325 ```sh 1326 curl -X POST --data '{ 1327 "jsonrpc": "2.0", 1328 "method": "platform.getTotalStake", 1329 "params": { 1330 "subnetID": "11111111111111111111111111111111LpoYY" 1331 }, 1332 "id": 1 1333 } 1334 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P 1335 ``` 1336 1337 **Example Response:** 1338 1339 ```json 1340 { 1341 "jsonrpc": "2.0", 1342 "result": { 1343 "stake": "279825917679866811", 1344 "weight": "279825917679866811" 1345 }, 1346 "id": 1 1347 } 1348 ``` 1349 1350 #### Subnet Example 1351 1352 **Example Call:** 1353 1354 ```sh 1355 curl -X POST --data '{ 1356 "jsonrpc": "2.0", 1357 "method": "platform.getTotalStake", 1358 "params": { 1359 "subnetID": "2bRCr6B4MiEfSjidDwxDpdCyviwnfUVqB2HGwhm947w9YYqb7r", 1360 }, 1361 "id": 1 1362 } 1363 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/P 1364 ``` 1365 1366 **Example Response:** 1367 1368 ```json 1369 { 1370 "jsonrpc": "2.0", 1371 "result": { 1372 "weight": "100000" 1373 }, 1374 "id": 1 1375 } 1376 ``` 1377 1378 ### `platform.getTx` 1379 1380 Gets a transaction by its ID. 1381 1382 Optional `encoding` parameter to specify the format for the returned transaction. Can be either 1383 `hex` or `json`. Defaults to `hex`. 1384 1385 **Signature:** 1386 1387 ```sh 1388 platform.getTx({ 1389 txID: string, 1390 encoding: string // optional 1391 }) -> { 1392 tx: string, 1393 encoding: string, 1394 } 1395 ``` 1396 1397 **Example Call:** 1398 1399 ```sh 1400 curl -X POST --data '{ 1401 "jsonrpc": "2.0", 1402 "method": "platform.getTx", 1403 "params": { 1404 "txID":"28KVjSw5h3XKGuNpJXWY74EdnGq4TUWvCgEtJPymgQTvudiugb", 1405 "encoding": "json" 1406 }, 1407 "id": 1 1408 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P 1409 ``` 1410 1411 **Example Response:** 1412 1413 ```json 1414 { 1415 "jsonrpc": "2.0", 1416 "result": { 1417 "tx": { 1418 "unsignedTx": { 1419 "networkID": 1, 1420 "blockchainID": "11111111111111111111111111111111LpoYY", 1421 "outputs": [], 1422 "inputs": [ 1423 { 1424 "txID": "NXNJHKeaJyjjWVSq341t6LGQP5UNz796o1crpHPByv1TKp9ZP", 1425 "outputIndex": 0, 1426 "assetID": "FvwEAhmxKfeiG8SnEvq42hc6whRyY3EFYAvebMqDNDGCgxN5Z", 1427 "fxID": "spdxUxVJQbX85MGxMHbKw1sHxMnSqJ3QBzDyDYEP3h6TLuxqQ", 1428 "input": { 1429 "amount": 20824279595, 1430 "signatureIndices": [0] 1431 } 1432 }, 1433 { 1434 "txID": "2ahK5SzD8iqi5KBqpKfxrnWtrEoVwQCqJsMoB9kvChCaHgAQC9", 1435 "outputIndex": 1, 1436 "assetID": "FvwEAhmxKfeiG8SnEvq42hc6whRyY3EFYAvebMqDNDGCgxN5Z", 1437 "fxID": "spdxUxVJQbX85MGxMHbKw1sHxMnSqJ3QBzDyDYEP3h6TLuxqQ", 1438 "input": { 1439 "amount": 28119890783, 1440 "signatureIndices": [0] 1441 } 1442 } 1443 ], 1444 "memo": "0x", 1445 "validator": { 1446 "nodeID": "NodeID-VT3YhgFaWEzy4Ap937qMeNEDscCammzG", 1447 "start": 1682945406, 1448 "end": 1684155006, 1449 "weight": 48944170378 1450 }, 1451 "stake": [ 1452 { 1453 "assetID": "FvwEAhmxKfeiG8SnEvq42hc6whRyY3EFYAvebMqDNDGCgxN5Z", 1454 "fxID": "spdxUxVJQbX85MGxMHbKw1sHxMnSqJ3QBzDyDYEP3h6TLuxqQ", 1455 "output": { 1456 "addresses": ["P-avax1tnuesf6cqwnjw7fxjyk7lhch0vhf0v95wj5jvy"], 1457 "amount": 48944170378, 1458 "locktime": 0, 1459 "threshold": 1 1460 } 1461 } 1462 ], 1463 "rewardsOwner": { 1464 "addresses": ["P-avax19zfygxaf59stehzedhxjesads0p5jdvfeedal0"], 1465 "locktime": 0, 1466 "threshold": 1 1467 } 1468 }, 1469 "credentials": [ 1470 { 1471 "signatures": [ 1472 "0x6954e90b98437646fde0c1d54c12190fc23ae5e319c4d95dda56b53b4a23e43825251289cdc3728f1f1e0d48eac20e5c8f097baa9b49ea8a3cb6a41bb272d16601" 1473 ] 1474 }, 1475 { 1476 "signatures": [ 1477 "0x6954e90b98437646fde0c1d54c12190fc23ae5e319c4d95dda56b53b4a23e43825251289cdc3728f1f1e0d48eac20e5c8f097baa9b49ea8a3cb6a41bb272d16601" 1478 ] 1479 } 1480 ], 1481 "id": "28KVjSw5h3XKGuNpJXWY74EdnGq4TUWvCgEtJPymgQTvudiugb" 1482 }, 1483 "encoding": "json" 1484 }, 1485 "id": 1 1486 } 1487 ``` 1488 1489 ### `platform.getTxStatus` 1490 1491 Gets a transaction’s status by its ID. If the transaction was dropped, response will include a 1492 `reason` field with more information why the transaction was dropped. 1493 1494 **Signature:** 1495 1496 ```sh 1497 platform.getTxStatus({ 1498 txID: string 1499 }) -> {status: string} 1500 ``` 1501 1502 `status` is one of: 1503 1504 - `Committed`: The transaction is (or will be) accepted by every node 1505 - `Processing`: The transaction is being voted on by this node 1506 - `Dropped`: The transaction will never be accepted by any node in the network, check `reason` field 1507 for more information 1508 - `Unknown`: The transaction hasn’t been seen by this node 1509 1510 **Example Call:** 1511 1512 ```sh 1513 curl -X POST --data '{ 1514 "jsonrpc": "2.0", 1515 "method": "platform.getTxStatus", 1516 "params": { 1517 "txID":"TAG9Ns1sa723mZy1GSoGqWipK6Mvpaj7CAswVJGM6MkVJDF9Q" 1518 }, 1519 "id": 1 1520 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P 1521 ``` 1522 1523 **Example Response:** 1524 1525 ```json 1526 { 1527 "jsonrpc": "2.0", 1528 "result": { 1529 "status": "Committed" 1530 }, 1531 "id": 1 1532 } 1533 ``` 1534 1535 ### `platform.getUTXOs` 1536 1537 Gets the UTXOs that reference a given set of addresses. 1538 1539 **Signature:** 1540 1541 ```sh 1542 platform.getUTXOs( 1543 { 1544 addresses: []string, 1545 limit: int, // optional 1546 startIndex: { // optional 1547 address: string, 1548 utxo: string 1549 }, 1550 sourceChain: string, // optional 1551 encoding: string, // optional 1552 }, 1553 ) -> 1554 { 1555 numFetched: int, 1556 utxos: []string, 1557 endIndex: { 1558 address: string, 1559 utxo: string 1560 }, 1561 encoding: string, 1562 } 1563 ``` 1564 1565 - `utxos` is a list of UTXOs such that each UTXO references at least one address in `addresses`. 1566 - At most `limit` UTXOs are returned. If `limit` is omitted or greater than 1024, it is set to 1024. 1567 - This method supports pagination. `endIndex` denotes the last UTXO returned. To get the next set of 1568 UTXOs, use the value of `endIndex` as `startIndex` in the next call. 1569 - If `startIndex` is omitted, will fetch all UTXOs up to `limit`. 1570 - When using pagination (that is when `startIndex` is provided), UTXOs are not guaranteed to be unique 1571 across multiple calls. That is, a UTXO may appear in the result of the first call, and then again 1572 in the second call. 1573 - When using pagination, consistency is not guaranteed across multiple calls. That is, the UTXO set 1574 of the addresses may have changed between calls. 1575 - `encoding` specifies the format for the returned UTXOs. Can only be `hex` when a value is 1576 provided. 1577 1578 #### **Example** 1579 1580 Suppose we want all UTXOs that reference at least one of 1581 `P-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5` and `P-avax1d09qn852zcy03sfc9hay2llmn9hsgnw4tp3dv6`. 1582 1583 ```sh 1584 curl -X POST --data '{ 1585 "jsonrpc":"2.0", 1586 "id" :1, 1587 "method" :"platform.getUTXOs", 1588 "params" :{ 1589 "addresses":["P-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5", "P-avax1d09qn852zcy03sfc9hay2llmn9hsgnw4tp3dv6"], 1590 "limit":5, 1591 "encoding": "hex" 1592 } 1593 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P 1594 ``` 1595 1596 This gives response: 1597 1598 ```json 1599 { 1600 "jsonrpc": "2.0", 1601 "result": { 1602 "numFetched": "5", 1603 "utxos": [ 1604 "0x0000a195046108a85e60f7a864bb567745a37f50c6af282103e47cc62f036cee404700000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f216c1f01765", 1605 "0x0000ae8b1b94444eed8de9a81b1222f00f1b4133330add23d8ac288bffa98b85271100000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f216473d042a", 1606 "0x0000731ce04b1feefa9f4291d869adc30a33463f315491e164d89be7d6d2d7890cfc00000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f21600dd3047", 1607 "0x0000b462030cc4734f24c0bc224cf0d16ee452ea6b67615517caffead123ab4fbf1500000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f216c71b387e", 1608 "0x000054f6826c39bc957c0c6d44b70f961a994898999179cc32d21eb09c1908d7167b00000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f2166290e79d" 1609 ], 1610 "endIndex": { 1611 "address": "P-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5", 1612 "utxo": "kbUThAUfmBXUmRgTpgD6r3nLj7rJUGho6xyht5nouNNypH45j" 1613 }, 1614 "encoding": "hex" 1615 }, 1616 "id": 1 1617 } 1618 ``` 1619 1620 Since `numFetched` is the same as `limit`, we can tell that there may be more UTXOs that were not 1621 fetched. We call the method again, this time with `startIndex`: 1622 1623 ```sh 1624 curl -X POST --data '{ 1625 "jsonrpc":"2.0", 1626 "id" :1, 1627 "method" :"platform.getUTXOs", 1628 "params" :{ 1629 "addresses":["P-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5"], 1630 "limit":5, 1631 "startIndex": { 1632 "address": "P-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5", 1633 "utxo": "0x62fc816bb209857923770c286192ab1f9e3f11e4a7d4ba0943111c3bbfeb9e4a5ea72fae" 1634 }, 1635 "encoding": "hex" 1636 } 1637 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P 1638 ``` 1639 1640 This gives response: 1641 1642 ```json 1643 { 1644 "jsonrpc": "2.0", 1645 "result": { 1646 "numFetched": "4", 1647 "utxos": [ 1648 "0x000020e182dd51ee4dcd31909fddd75bb3438d9431f8e4efce86a88a684f5c7fa09300000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f21662861d59", 1649 "0x0000a71ba36c475c18eb65dc90f6e85c4fd4a462d51c5de3ac2cbddf47db4d99284e00000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f21665f6f83f", 1650 "0x0000925424f61cb13e0fbdecc66e1270de68de9667b85baa3fdc84741d048daa69fa00000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f216afecf76a", 1651 "0x000082f30327514f819da6009fad92b5dba24d27db01e29ad7541aa8e6b6b554615c00000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f216779c2d59" 1652 ], 1653 "endIndex": { 1654 "address": "P-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5", 1655 "utxo": "21jG2RfqyHUUgkTLe2tUp6ETGLriSDTW3th8JXFbPRNiSZ11jK" 1656 }, 1657 "encoding": "hex" 1658 }, 1659 "id": 1 1660 } 1661 ``` 1662 1663 Since `numFetched` is less than `limit`, we know that we are done fetching UTXOs and don’t need to 1664 call this method again. 1665 1666 Suppose we want to fetch the UTXOs exported from the X Chain to the P Chain in order to build an 1667 ImportTx. Then we need to call GetUTXOs with the `sourceChain` argument in order to retrieve the 1668 atomic UTXOs: 1669 1670 ```sh 1671 curl -X POST --data '{ 1672 "jsonrpc":"2.0", 1673 "id" :1, 1674 "method" :"platform.getUTXOs", 1675 "params" :{ 1676 "addresses":["P-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5"], 1677 "sourceChain": "X", 1678 "encoding": "hex" 1679 } 1680 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P 1681 ``` 1682 1683 This gives response: 1684 1685 ```json 1686 { 1687 "jsonrpc": "2.0", 1688 "result": { 1689 "numFetched": "1", 1690 "utxos": [ 1691 "0x00001f989ffaf18a18a59bdfbf209342aa61c6a62a67e8639d02bb3c8ddab315c6fa0000000139c33a499ce4c33a3b09cdd2cfa01ae70dbf2d18b2d7d168524440e55d55008800000007000000746a528800000000000000000000000001000000013cb7d3842e8cee6a0ebd09f1fe884f6861e1b29cd704fe76" 1692 ], 1693 "endIndex": { 1694 "address": "P-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5", 1695 "utxo": "S5UKgWoVpoGFyxfisebmmRf8WqC7ZwcmYwS7XaDVZqoaFcCwK" 1696 }, 1697 "encoding": "hex" 1698 }, 1699 "id": 1 1700 } 1701 ``` 1702 1703 ### `platform.getValidatorsAt` 1704 1705 Get the validators and their weights of a Subnet or the Primary Network at a given P-Chain height. 1706 1707 **Signature:** 1708 1709 ```sh 1710 platform.getValidatorsAt( 1711 { 1712 height: int, 1713 subnetID: string, // optional 1714 } 1715 ) 1716 ``` 1717 1718 - `height` is the P-Chain height to get the validator set at. 1719 - `subnetID` is the Subnet ID to get the validator set of. If not given, gets validator set of the 1720 Primary Network. 1721 1722 **Example Call:** 1723 1724 ```bash 1725 curl -X POST --data '{ 1726 "jsonrpc": "2.0", 1727 "method": "platform.getValidatorsAt", 1728 "params": { 1729 "height":1 1730 }, 1731 "id": 1 1732 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P 1733 ``` 1734 1735 **Example Response:** 1736 1737 ```json 1738 { 1739 "jsonrpc": "2.0", 1740 "result": { 1741 "validators": { 1742 "NodeID-7Xhw2mDxuDS44j42TCB6U5579esbSt3Lg": 2000000000000000, 1743 "NodeID-GWPcbFJZFfZreETSoWjPimr846mXEKCtu": 2000000000000000, 1744 "NodeID-MFrZFVCXPv5iCn6M9K6XduxGTYp891xXZ": 2000000000000000, 1745 "NodeID-NFBbbJ4qCmNaCzeW7sxErhvWqvEQMnYcN": 2000000000000000, 1746 "NodeID-P7oB2McjBGgW2NXXWVYjV8JEDFoW9xDE5": 2000000000000000 1747 } 1748 }, 1749 "id": 1 1750 } 1751 ``` 1752 1753 ### `platform.issueTx` 1754 1755 Issue a transaction to the Platform Chain. 1756 1757 **Signature:** 1758 1759 ```sh 1760 platform.issueTx({ 1761 tx: string, 1762 encoding: string, // optional 1763 }) -> {txID: string} 1764 ``` 1765 1766 - `tx` is the byte representation of a transaction. 1767 - `encoding` specifies the encoding format for the transaction bytes. Can only be `hex` when a value 1768 is provided. 1769 - `txID` is the transaction’s ID. 1770 1771 **Example Call:** 1772 1773 ```sh 1774 curl -X POST --data '{ 1775 "jsonrpc": "2.0", 1776 "method": "platform.issueTx", 1777 "params": { 1778 "tx":"0x00000009de31b4d8b22991d51aa6aa1fc733f23a851a8c9400000000000186a0000000005f041280000000005f9ca900000030390000000000000001fceda8f90fcb5d30614b99d79fc4baa29307762668f16eb0259a57c2d3b78c875c86ec2045792d4df2d926c40f829196e0bb97ee697af71f5b0a966dabff749634c8b729855e937715b0e44303fd1014daedc752006011b730", 1779 "encoding": "hex" 1780 }, 1781 "id": 1 1782 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P 1783 ``` 1784 1785 **Example Response:** 1786 1787 ```json 1788 { 1789 "jsonrpc": "2.0", 1790 "result": { 1791 "txID": "G3BuH6ytQ2averrLxJJugjWZHTRubzCrUZEXoheG5JMqL5ccY" 1792 }, 1793 "id": 1 1794 } 1795 ``` 1796 1797 ### `platform.listAddresses` 1798 1799 :::caution 1800 1801 Deprecated as of [**v1.9.12**](https://github.com/ava-labs/avalanchego/releases/tag/v1.9.12). 1802 1803 ::: 1804 1805 :::warning 1806 1807 Not recommended for use on Mainnet. See warning notice in [Keystore API](/reference/avalanchego/keystore-api.md). 1808 1809 ::: 1810 1811 List addresses controlled by the given user. 1812 1813 **Signature:** 1814 1815 ```sh 1816 platform.listAddresses({ 1817 username: string, 1818 password: string 1819 }) -> {addresses: []string} 1820 ``` 1821 1822 **Example Call:** 1823 1824 ```sh 1825 curl -X POST --data '{ 1826 "jsonrpc": "2.0", 1827 "method": "platform.listAddresses", 1828 "params": { 1829 "username":"myUsername", 1830 "password":"myPassword" 1831 }, 1832 "id": 1 1833 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P 1834 ``` 1835 1836 **Example Response:** 1837 1838 ```json 1839 { 1840 "jsonrpc": "2.0", 1841 "result": { 1842 "addresses": ["P-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5"] 1843 }, 1844 "id": 1 1845 } 1846 ``` 1847 1848 ### `platform.sampleValidators` 1849 1850 Sample validators from the specified Subnet. 1851 1852 **Signature:** 1853 1854 ```sh 1855 platform.sampleValidators( 1856 { 1857 size: int, 1858 subnetID: string, // optional 1859 } 1860 ) -> 1861 { 1862 validators: []string 1863 } 1864 ``` 1865 1866 - `size` is the number of validators to sample. 1867 - `subnetID` is the Subnet to sampled from. If omitted, defaults to the Primary Network. 1868 - Each element of `validators` is the ID of a validator. 1869 1870 **Example Call:** 1871 1872 ```sh 1873 curl -X POST --data '{ 1874 "jsonrpc":"2.0", 1875 "id" :1, 1876 "method" :"platform.sampleValidators", 1877 "params" :{ 1878 "size":2 1879 } 1880 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P 1881 ``` 1882 1883 **Example Response:** 1884 1885 ```json 1886 { 1887 "jsonrpc": "2.0", 1888 "id": 1, 1889 "result": { 1890 "validators": [ 1891 "NodeID-MFrZFVCXPv5iCn6M9K6XduxGTYp891xXZ", 1892 "NodeID-NFBbbJ4qCmNaCzeW7sxErhvWqvEQMnYcN" 1893 ] 1894 } 1895 } 1896 ``` 1897 1898 ### `platform.validatedBy` 1899 1900 Get the Subnet that validates a given blockchain. 1901 1902 **Signature:** 1903 1904 ```sh 1905 platform.validatedBy( 1906 { 1907 blockchainID: string 1908 } 1909 ) -> {subnetID: string} 1910 ``` 1911 1912 - `blockchainID` is the blockchain’s ID. 1913 - `subnetID` is the ID of the Subnet that validates the blockchain. 1914 1915 **Example Call:** 1916 1917 ```sh 1918 curl -X POST --data '{ 1919 "jsonrpc": "2.0", 1920 "method": "platform.validatedBy", 1921 "params": { 1922 "blockchainID": "KDYHHKjM4yTJTT8H8qPs5KXzE6gQH5TZrmP1qVr1P6qECj3XN" 1923 }, 1924 "id": 1 1925 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P 1926 ``` 1927 1928 **Example Response:** 1929 1930 ```json 1931 { 1932 "jsonrpc": "2.0", 1933 "result": { 1934 "subnetID": "2bRCr6B4MiEfSjidDwxDpdCyviwnfUVqB2HGwhm947w9YYqb7r" 1935 }, 1936 "id": 1 1937 } 1938 ``` 1939 1940 ### `platform.validates` 1941 1942 Get the IDs of the blockchains a Subnet validates. 1943 1944 **Signature:** 1945 1946 ```sh 1947 platform.validates( 1948 { 1949 subnetID: string 1950 } 1951 ) -> {blockchainIDs: []string} 1952 ``` 1953 1954 - `subnetID` is the Subnet’s ID. 1955 - Each element of `blockchainIDs` is the ID of a blockchain the Subnet validates. 1956 1957 **Example Call:** 1958 1959 ```sh 1960 curl -X POST --data '{ 1961 "jsonrpc": "2.0", 1962 "method": "platform.validates", 1963 "params": { 1964 "subnetID":"2bRCr6B4MiEfSjidDwxDpdCyviwnfUVqB2HGwhm947w9YYqb7r" 1965 }, 1966 "id": 1 1967 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P 1968 ``` 1969 1970 **Example Response:** 1971 1972 ```json 1973 { 1974 "jsonrpc": "2.0", 1975 "result": { 1976 "blockchainIDs": [ 1977 "KDYHHKjM4yTJTT8H8qPs5KXzE6gQH5TZrmP1qVr1P6qECj3XN", 1978 "2TtHFqEAAJ6b33dromYMqfgavGPF3iCpdG3hwNMiart2aB5QHi" 1979 ] 1980 }, 1981 "id": 1 1982 } 1983 ```