github.com/ava-labs/avalanchego@v1.11.11/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. (Deprecated: uptime is deprecated for Subnet Validators. It will be available only for Primary Network Validators.) 700 - `connected` is if the node is connected and tracks the Subnet. (Deprecated: connected is deprecated for Subnet Validators. It will be available only for Primary Network Validators.) 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.getSubnet` 1206 1207 Get owners and elastic info about the Subnet. 1208 1209 **Signature:** 1210 1211 ```sh 1212 platform.getSubnet({ 1213 subnetID: string 1214 }) -> 1215 { 1216 isPermissioned: bool, 1217 controlKeys: []string, 1218 threshold: string, 1219 locktime: string, 1220 subnetTransformationTxID: string 1221 } 1222 ``` 1223 1224 - `subnetID` is the ID of the Subnet to get information about. If omitted, fails. 1225 - `threshold` signatures from addresses in `controlKeys` are needed to make changes to 1226 a permissioned subnet. If the Subnet is a PoS Subnet, then `threshold` will be `0` and `controlKeys` 1227 will be empty. 1228 - changes can not be made into the subnet until `locktime` is in the past. 1229 - `subnetTransformationTxID` is the ID of the transaction that changed the subnet into a elastic one, 1230 for when this change was performed. 1231 1232 **Example Call:** 1233 1234 ```sh 1235 curl -X POST --data '{ 1236 "jsonrpc": "2.0", 1237 "method": "platform.getSubnet", 1238 "params": {"subnetID":"Vz2ArUpigHt7fyE79uF3gAXvTPLJi2LGgZoMpgNPHowUZJxBb"}, 1239 "id": 1 1240 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P 1241 ``` 1242 1243 **Example Response:** 1244 1245 ```json 1246 { 1247 "jsonrpc": "2.0", 1248 "result": { 1249 "isPermissioned": true, 1250 "controlKeys": ["P-fuji1ztvstx6naeg6aarfd047fzppdt8v4gsah88e0c","P-fuji193kvt4grqewv6ce2x59wnhydr88xwdgfcedyr3"], 1251 "threshold": "1", 1252 "locktime": "0", 1253 "subnetTransformationTxID": "11111111111111111111111111111111LpoYY" 1254 }, 1255 "id": 1 1256 } 1257 ``` 1258 1259 ### `platform.getSubnets` 1260 1261 :::caution 1262 1263 Deprecated as of [**v1.9.12**](https://github.com/ava-labs/avalanchego/releases/tag/v1.9.12). 1264 1265 ::: 1266 1267 Get info about the Subnets. 1268 1269 **Signature:** 1270 1271 ```sh 1272 platform.getSubnets({ 1273 ids: []string 1274 }) -> 1275 { 1276 subnets: []{ 1277 id: string, 1278 controlKeys: []string, 1279 threshold: string 1280 } 1281 } 1282 ``` 1283 1284 - `ids` are the IDs of the Subnets to get information about. If omitted, gets information about all 1285 Subnets. 1286 - `id` is the Subnet’s ID. 1287 - `threshold` signatures from addresses in `controlKeys` are needed to add a validator to the 1288 Subnet. If the Subnet is a PoS Subnet, then `threshold` will be `0` and `controlKeys` will be 1289 empty. 1290 1291 See [here](/nodes/validate/add-a-validator.md) for information on adding a validator to a 1292 Subnet. 1293 1294 **Example Call:** 1295 1296 ```sh 1297 curl -X POST --data '{ 1298 "jsonrpc": "2.0", 1299 "method": "platform.getSubnets", 1300 "params": {"ids":["hW8Ma7dLMA7o4xmJf3AXBbo17bXzE7xnThUd3ypM4VAWo1sNJ"]}, 1301 "id": 1 1302 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P 1303 ``` 1304 1305 **Example Response:** 1306 1307 ```json 1308 { 1309 "jsonrpc": "2.0", 1310 "result": { 1311 "subnets": [ 1312 { 1313 "id": "hW8Ma7dLMA7o4xmJf3AXBbo17bXzE7xnThUd3ypM4VAWo1sNJ", 1314 "controlKeys": [ 1315 "KNjXsaA1sZsaKCD1cd85YXauDuxshTes2", 1316 "Aiz4eEt5xv9t4NCnAWaQJFNz5ABqLtJkR" 1317 ], 1318 "threshold": "2" 1319 } 1320 ] 1321 }, 1322 "id": 1 1323 } 1324 ``` 1325 1326 ### `platform.getTimestamp` 1327 1328 Get the current P-Chain timestamp. 1329 1330 **Signature:** 1331 1332 ```sh 1333 platform.getTimestamp() -> {time: string} 1334 ``` 1335 1336 **Example Call:** 1337 1338 ```sh 1339 curl -X POST --data '{ 1340 "jsonrpc": "2.0", 1341 "method": "platform.getTimestamp", 1342 "params": {}, 1343 "id": 1 1344 } 1345 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P 1346 ``` 1347 1348 **Example Response:** 1349 1350 ```json 1351 { 1352 "jsonrpc": "2.0", 1353 "result": { 1354 "timestamp": "2021-09-07T00:00:00-04:00" 1355 }, 1356 "id": 1 1357 } 1358 ``` 1359 1360 ### `platform.getTotalStake` 1361 1362 Get the total amount of tokens staked on the requested Subnet. 1363 1364 **Signature:** 1365 1366 ```sh 1367 platform.getTotalStake({ 1368 subnetID: string 1369 }) -> { 1370 stake: int 1371 weight: int 1372 } 1373 ``` 1374 1375 #### Primary Network Example 1376 1377 **Example Call:** 1378 1379 ```sh 1380 curl -X POST --data '{ 1381 "jsonrpc": "2.0", 1382 "method": "platform.getTotalStake", 1383 "params": { 1384 "subnetID": "11111111111111111111111111111111LpoYY" 1385 }, 1386 "id": 1 1387 } 1388 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P 1389 ``` 1390 1391 **Example Response:** 1392 1393 ```json 1394 { 1395 "jsonrpc": "2.0", 1396 "result": { 1397 "stake": "279825917679866811", 1398 "weight": "279825917679866811" 1399 }, 1400 "id": 1 1401 } 1402 ``` 1403 1404 #### Subnet Example 1405 1406 **Example Call:** 1407 1408 ```sh 1409 curl -X POST --data '{ 1410 "jsonrpc": "2.0", 1411 "method": "platform.getTotalStake", 1412 "params": { 1413 "subnetID": "2bRCr6B4MiEfSjidDwxDpdCyviwnfUVqB2HGwhm947w9YYqb7r", 1414 }, 1415 "id": 1 1416 } 1417 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/P 1418 ``` 1419 1420 **Example Response:** 1421 1422 ```json 1423 { 1424 "jsonrpc": "2.0", 1425 "result": { 1426 "weight": "100000" 1427 }, 1428 "id": 1 1429 } 1430 ``` 1431 1432 ### `platform.getTx` 1433 1434 Gets a transaction by its ID. 1435 1436 Optional `encoding` parameter to specify the format for the returned transaction. Can be either 1437 `hex` or `json`. Defaults to `hex`. 1438 1439 **Signature:** 1440 1441 ```sh 1442 platform.getTx({ 1443 txID: string, 1444 encoding: string // optional 1445 }) -> { 1446 tx: string, 1447 encoding: string, 1448 } 1449 ``` 1450 1451 **Example Call:** 1452 1453 ```sh 1454 curl -X POST --data '{ 1455 "jsonrpc": "2.0", 1456 "method": "platform.getTx", 1457 "params": { 1458 "txID":"28KVjSw5h3XKGuNpJXWY74EdnGq4TUWvCgEtJPymgQTvudiugb", 1459 "encoding": "json" 1460 }, 1461 "id": 1 1462 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P 1463 ``` 1464 1465 **Example Response:** 1466 1467 ```json 1468 { 1469 "jsonrpc": "2.0", 1470 "result": { 1471 "tx": { 1472 "unsignedTx": { 1473 "networkID": 1, 1474 "blockchainID": "11111111111111111111111111111111LpoYY", 1475 "outputs": [], 1476 "inputs": [ 1477 { 1478 "txID": "NXNJHKeaJyjjWVSq341t6LGQP5UNz796o1crpHPByv1TKp9ZP", 1479 "outputIndex": 0, 1480 "assetID": "FvwEAhmxKfeiG8SnEvq42hc6whRyY3EFYAvebMqDNDGCgxN5Z", 1481 "fxID": "spdxUxVJQbX85MGxMHbKw1sHxMnSqJ3QBzDyDYEP3h6TLuxqQ", 1482 "input": { 1483 "amount": 20824279595, 1484 "signatureIndices": [0] 1485 } 1486 }, 1487 { 1488 "txID": "2ahK5SzD8iqi5KBqpKfxrnWtrEoVwQCqJsMoB9kvChCaHgAQC9", 1489 "outputIndex": 1, 1490 "assetID": "FvwEAhmxKfeiG8SnEvq42hc6whRyY3EFYAvebMqDNDGCgxN5Z", 1491 "fxID": "spdxUxVJQbX85MGxMHbKw1sHxMnSqJ3QBzDyDYEP3h6TLuxqQ", 1492 "input": { 1493 "amount": 28119890783, 1494 "signatureIndices": [0] 1495 } 1496 } 1497 ], 1498 "memo": "0x", 1499 "validator": { 1500 "nodeID": "NodeID-VT3YhgFaWEzy4Ap937qMeNEDscCammzG", 1501 "start": 1682945406, 1502 "end": 1684155006, 1503 "weight": 48944170378 1504 }, 1505 "stake": [ 1506 { 1507 "assetID": "FvwEAhmxKfeiG8SnEvq42hc6whRyY3EFYAvebMqDNDGCgxN5Z", 1508 "fxID": "spdxUxVJQbX85MGxMHbKw1sHxMnSqJ3QBzDyDYEP3h6TLuxqQ", 1509 "output": { 1510 "addresses": ["P-avax1tnuesf6cqwnjw7fxjyk7lhch0vhf0v95wj5jvy"], 1511 "amount": 48944170378, 1512 "locktime": 0, 1513 "threshold": 1 1514 } 1515 } 1516 ], 1517 "rewardsOwner": { 1518 "addresses": ["P-avax19zfygxaf59stehzedhxjesads0p5jdvfeedal0"], 1519 "locktime": 0, 1520 "threshold": 1 1521 } 1522 }, 1523 "credentials": [ 1524 { 1525 "signatures": [ 1526 "0x6954e90b98437646fde0c1d54c12190fc23ae5e319c4d95dda56b53b4a23e43825251289cdc3728f1f1e0d48eac20e5c8f097baa9b49ea8a3cb6a41bb272d16601" 1527 ] 1528 }, 1529 { 1530 "signatures": [ 1531 "0x6954e90b98437646fde0c1d54c12190fc23ae5e319c4d95dda56b53b4a23e43825251289cdc3728f1f1e0d48eac20e5c8f097baa9b49ea8a3cb6a41bb272d16601" 1532 ] 1533 } 1534 ], 1535 "id": "28KVjSw5h3XKGuNpJXWY74EdnGq4TUWvCgEtJPymgQTvudiugb" 1536 }, 1537 "encoding": "json" 1538 }, 1539 "id": 1 1540 } 1541 ``` 1542 1543 ### `platform.getTxStatus` 1544 1545 Gets a transaction’s status by its ID. If the transaction was dropped, response will include a 1546 `reason` field with more information why the transaction was dropped. 1547 1548 **Signature:** 1549 1550 ```sh 1551 platform.getTxStatus({ 1552 txID: string 1553 }) -> {status: string} 1554 ``` 1555 1556 `status` is one of: 1557 1558 - `Committed`: The transaction is (or will be) accepted by every node 1559 - `Processing`: The transaction is being voted on by this node 1560 - `Dropped`: The transaction will never be accepted by any node in the network, check `reason` field 1561 for more information 1562 - `Unknown`: The transaction hasn’t been seen by this node 1563 1564 **Example Call:** 1565 1566 ```sh 1567 curl -X POST --data '{ 1568 "jsonrpc": "2.0", 1569 "method": "platform.getTxStatus", 1570 "params": { 1571 "txID":"TAG9Ns1sa723mZy1GSoGqWipK6Mvpaj7CAswVJGM6MkVJDF9Q" 1572 }, 1573 "id": 1 1574 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P 1575 ``` 1576 1577 **Example Response:** 1578 1579 ```json 1580 { 1581 "jsonrpc": "2.0", 1582 "result": { 1583 "status": "Committed" 1584 }, 1585 "id": 1 1586 } 1587 ``` 1588 1589 ### `platform.getUTXOs` 1590 1591 Gets the UTXOs that reference a given set of addresses. 1592 1593 **Signature:** 1594 1595 ```sh 1596 platform.getUTXOs( 1597 { 1598 addresses: []string, 1599 limit: int, // optional 1600 startIndex: { // optional 1601 address: string, 1602 utxo: string 1603 }, 1604 sourceChain: string, // optional 1605 encoding: string, // optional 1606 }, 1607 ) -> 1608 { 1609 numFetched: int, 1610 utxos: []string, 1611 endIndex: { 1612 address: string, 1613 utxo: string 1614 }, 1615 encoding: string, 1616 } 1617 ``` 1618 1619 - `utxos` is a list of UTXOs such that each UTXO references at least one address in `addresses`. 1620 - At most `limit` UTXOs are returned. If `limit` is omitted or greater than 1024, it is set to 1024. 1621 - This method supports pagination. `endIndex` denotes the last UTXO returned. To get the next set of 1622 UTXOs, use the value of `endIndex` as `startIndex` in the next call. 1623 - If `startIndex` is omitted, will fetch all UTXOs up to `limit`. 1624 - When using pagination (that is when `startIndex` is provided), UTXOs are not guaranteed to be unique 1625 across multiple calls. That is, a UTXO may appear in the result of the first call, and then again 1626 in the second call. 1627 - When using pagination, consistency is not guaranteed across multiple calls. That is, the UTXO set 1628 of the addresses may have changed between calls. 1629 - `encoding` specifies the format for the returned UTXOs. Can only be `hex` when a value is 1630 provided. 1631 1632 #### **Example** 1633 1634 Suppose we want all UTXOs that reference at least one of 1635 `P-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5` and `P-avax1d09qn852zcy03sfc9hay2llmn9hsgnw4tp3dv6`. 1636 1637 ```sh 1638 curl -X POST --data '{ 1639 "jsonrpc":"2.0", 1640 "id" :1, 1641 "method" :"platform.getUTXOs", 1642 "params" :{ 1643 "addresses":["P-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5", "P-avax1d09qn852zcy03sfc9hay2llmn9hsgnw4tp3dv6"], 1644 "limit":5, 1645 "encoding": "hex" 1646 } 1647 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P 1648 ``` 1649 1650 This gives response: 1651 1652 ```json 1653 { 1654 "jsonrpc": "2.0", 1655 "result": { 1656 "numFetched": "5", 1657 "utxos": [ 1658 "0x0000a195046108a85e60f7a864bb567745a37f50c6af282103e47cc62f036cee404700000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f216c1f01765", 1659 "0x0000ae8b1b94444eed8de9a81b1222f00f1b4133330add23d8ac288bffa98b85271100000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f216473d042a", 1660 "0x0000731ce04b1feefa9f4291d869adc30a33463f315491e164d89be7d6d2d7890cfc00000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f21600dd3047", 1661 "0x0000b462030cc4734f24c0bc224cf0d16ee452ea6b67615517caffead123ab4fbf1500000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f216c71b387e", 1662 "0x000054f6826c39bc957c0c6d44b70f961a994898999179cc32d21eb09c1908d7167b00000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f2166290e79d" 1663 ], 1664 "endIndex": { 1665 "address": "P-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5", 1666 "utxo": "kbUThAUfmBXUmRgTpgD6r3nLj7rJUGho6xyht5nouNNypH45j" 1667 }, 1668 "encoding": "hex" 1669 }, 1670 "id": 1 1671 } 1672 ``` 1673 1674 Since `numFetched` is the same as `limit`, we can tell that there may be more UTXOs that were not 1675 fetched. We call the method again, this time with `startIndex`: 1676 1677 ```sh 1678 curl -X POST --data '{ 1679 "jsonrpc":"2.0", 1680 "id" :1, 1681 "method" :"platform.getUTXOs", 1682 "params" :{ 1683 "addresses":["P-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5"], 1684 "limit":5, 1685 "startIndex": { 1686 "address": "P-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5", 1687 "utxo": "0x62fc816bb209857923770c286192ab1f9e3f11e4a7d4ba0943111c3bbfeb9e4a5ea72fae" 1688 }, 1689 "encoding": "hex" 1690 } 1691 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P 1692 ``` 1693 1694 This gives response: 1695 1696 ```json 1697 { 1698 "jsonrpc": "2.0", 1699 "result": { 1700 "numFetched": "4", 1701 "utxos": [ 1702 "0x000020e182dd51ee4dcd31909fddd75bb3438d9431f8e4efce86a88a684f5c7fa09300000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f21662861d59", 1703 "0x0000a71ba36c475c18eb65dc90f6e85c4fd4a462d51c5de3ac2cbddf47db4d99284e00000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f21665f6f83f", 1704 "0x0000925424f61cb13e0fbdecc66e1270de68de9667b85baa3fdc84741d048daa69fa00000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f216afecf76a", 1705 "0x000082f30327514f819da6009fad92b5dba24d27db01e29ad7541aa8e6b6b554615c00000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f216779c2d59" 1706 ], 1707 "endIndex": { 1708 "address": "P-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5", 1709 "utxo": "21jG2RfqyHUUgkTLe2tUp6ETGLriSDTW3th8JXFbPRNiSZ11jK" 1710 }, 1711 "encoding": "hex" 1712 }, 1713 "id": 1 1714 } 1715 ``` 1716 1717 Since `numFetched` is less than `limit`, we know that we are done fetching UTXOs and don’t need to 1718 call this method again. 1719 1720 Suppose we want to fetch the UTXOs exported from the X Chain to the P Chain in order to build an 1721 ImportTx. Then we need to call GetUTXOs with the `sourceChain` argument in order to retrieve the 1722 atomic UTXOs: 1723 1724 ```sh 1725 curl -X POST --data '{ 1726 "jsonrpc":"2.0", 1727 "id" :1, 1728 "method" :"platform.getUTXOs", 1729 "params" :{ 1730 "addresses":["P-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5"], 1731 "sourceChain": "X", 1732 "encoding": "hex" 1733 } 1734 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P 1735 ``` 1736 1737 This gives response: 1738 1739 ```json 1740 { 1741 "jsonrpc": "2.0", 1742 "result": { 1743 "numFetched": "1", 1744 "utxos": [ 1745 "0x00001f989ffaf18a18a59bdfbf209342aa61c6a62a67e8639d02bb3c8ddab315c6fa0000000139c33a499ce4c33a3b09cdd2cfa01ae70dbf2d18b2d7d168524440e55d55008800000007000000746a528800000000000000000000000001000000013cb7d3842e8cee6a0ebd09f1fe884f6861e1b29cd704fe76" 1746 ], 1747 "endIndex": { 1748 "address": "P-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5", 1749 "utxo": "S5UKgWoVpoGFyxfisebmmRf8WqC7ZwcmYwS7XaDVZqoaFcCwK" 1750 }, 1751 "encoding": "hex" 1752 }, 1753 "id": 1 1754 } 1755 ``` 1756 1757 ### `platform.getValidatorsAt` 1758 1759 Get the validators and their weights of a Subnet or the Primary Network at a given P-Chain height. 1760 1761 **Signature:** 1762 1763 ```sh 1764 platform.getValidatorsAt( 1765 { 1766 height: int, 1767 subnetID: string, // optional 1768 } 1769 ) 1770 ``` 1771 1772 - `height` is the P-Chain height to get the validator set at. 1773 - `subnetID` is the Subnet ID to get the validator set of. If not given, gets validator set of the 1774 Primary Network. 1775 1776 **Example Call:** 1777 1778 ```bash 1779 curl -X POST --data '{ 1780 "jsonrpc": "2.0", 1781 "method": "platform.getValidatorsAt", 1782 "params": { 1783 "height":1 1784 }, 1785 "id": 1 1786 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P 1787 ``` 1788 1789 **Example Response:** 1790 1791 ```json 1792 { 1793 "jsonrpc": "2.0", 1794 "result": { 1795 "validators": { 1796 "NodeID-7Xhw2mDxuDS44j42TCB6U5579esbSt3Lg": 2000000000000000, 1797 "NodeID-GWPcbFJZFfZreETSoWjPimr846mXEKCtu": 2000000000000000, 1798 "NodeID-MFrZFVCXPv5iCn6M9K6XduxGTYp891xXZ": 2000000000000000, 1799 "NodeID-NFBbbJ4qCmNaCzeW7sxErhvWqvEQMnYcN": 2000000000000000, 1800 "NodeID-P7oB2McjBGgW2NXXWVYjV8JEDFoW9xDE5": 2000000000000000 1801 } 1802 }, 1803 "id": 1 1804 } 1805 ``` 1806 1807 ### `platform.issueTx` 1808 1809 Issue a transaction to the Platform Chain. 1810 1811 **Signature:** 1812 1813 ```sh 1814 platform.issueTx({ 1815 tx: string, 1816 encoding: string, // optional 1817 }) -> {txID: string} 1818 ``` 1819 1820 - `tx` is the byte representation of a transaction. 1821 - `encoding` specifies the encoding format for the transaction bytes. Can only be `hex` when a value 1822 is provided. 1823 - `txID` is the transaction’s ID. 1824 1825 **Example Call:** 1826 1827 ```sh 1828 curl -X POST --data '{ 1829 "jsonrpc": "2.0", 1830 "method": "platform.issueTx", 1831 "params": { 1832 "tx":"0x00000009de31b4d8b22991d51aa6aa1fc733f23a851a8c9400000000000186a0000000005f041280000000005f9ca900000030390000000000000001fceda8f90fcb5d30614b99d79fc4baa29307762668f16eb0259a57c2d3b78c875c86ec2045792d4df2d926c40f829196e0bb97ee697af71f5b0a966dabff749634c8b729855e937715b0e44303fd1014daedc752006011b730", 1833 "encoding": "hex" 1834 }, 1835 "id": 1 1836 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P 1837 ``` 1838 1839 **Example Response:** 1840 1841 ```json 1842 { 1843 "jsonrpc": "2.0", 1844 "result": { 1845 "txID": "G3BuH6ytQ2averrLxJJugjWZHTRubzCrUZEXoheG5JMqL5ccY" 1846 }, 1847 "id": 1 1848 } 1849 ``` 1850 1851 ### `platform.listAddresses` 1852 1853 :::caution 1854 1855 Deprecated as of [**v1.9.12**](https://github.com/ava-labs/avalanchego/releases/tag/v1.9.12). 1856 1857 ::: 1858 1859 :::warning 1860 1861 Not recommended for use on Mainnet. See warning notice in [Keystore API](/reference/avalanchego/keystore-api.md). 1862 1863 ::: 1864 1865 List addresses controlled by the given user. 1866 1867 **Signature:** 1868 1869 ```sh 1870 platform.listAddresses({ 1871 username: string, 1872 password: string 1873 }) -> {addresses: []string} 1874 ``` 1875 1876 **Example Call:** 1877 1878 ```sh 1879 curl -X POST --data '{ 1880 "jsonrpc": "2.0", 1881 "method": "platform.listAddresses", 1882 "params": { 1883 "username":"myUsername", 1884 "password":"myPassword" 1885 }, 1886 "id": 1 1887 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P 1888 ``` 1889 1890 **Example Response:** 1891 1892 ```json 1893 { 1894 "jsonrpc": "2.0", 1895 "result": { 1896 "addresses": ["P-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5"] 1897 }, 1898 "id": 1 1899 } 1900 ``` 1901 1902 ### `platform.sampleValidators` 1903 1904 Sample validators from the specified Subnet. 1905 1906 **Signature:** 1907 1908 ```sh 1909 platform.sampleValidators( 1910 { 1911 size: int, 1912 subnetID: string, // optional 1913 } 1914 ) -> 1915 { 1916 validators: []string 1917 } 1918 ``` 1919 1920 - `size` is the number of validators to sample. 1921 - `subnetID` is the Subnet to sampled from. If omitted, defaults to the Primary Network. 1922 - Each element of `validators` is the ID of a validator. 1923 1924 **Example Call:** 1925 1926 ```sh 1927 curl -X POST --data '{ 1928 "jsonrpc":"2.0", 1929 "id" :1, 1930 "method" :"platform.sampleValidators", 1931 "params" :{ 1932 "size":2 1933 } 1934 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P 1935 ``` 1936 1937 **Example Response:** 1938 1939 ```json 1940 { 1941 "jsonrpc": "2.0", 1942 "id": 1, 1943 "result": { 1944 "validators": [ 1945 "NodeID-MFrZFVCXPv5iCn6M9K6XduxGTYp891xXZ", 1946 "NodeID-NFBbbJ4qCmNaCzeW7sxErhvWqvEQMnYcN" 1947 ] 1948 } 1949 } 1950 ``` 1951 1952 ### `platform.validatedBy` 1953 1954 Get the Subnet that validates a given blockchain. 1955 1956 **Signature:** 1957 1958 ```sh 1959 platform.validatedBy( 1960 { 1961 blockchainID: string 1962 } 1963 ) -> {subnetID: string} 1964 ``` 1965 1966 - `blockchainID` is the blockchain’s ID. 1967 - `subnetID` is the ID of the Subnet that validates the blockchain. 1968 1969 **Example Call:** 1970 1971 ```sh 1972 curl -X POST --data '{ 1973 "jsonrpc": "2.0", 1974 "method": "platform.validatedBy", 1975 "params": { 1976 "blockchainID": "KDYHHKjM4yTJTT8H8qPs5KXzE6gQH5TZrmP1qVr1P6qECj3XN" 1977 }, 1978 "id": 1 1979 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P 1980 ``` 1981 1982 **Example Response:** 1983 1984 ```json 1985 { 1986 "jsonrpc": "2.0", 1987 "result": { 1988 "subnetID": "2bRCr6B4MiEfSjidDwxDpdCyviwnfUVqB2HGwhm947w9YYqb7r" 1989 }, 1990 "id": 1 1991 } 1992 ``` 1993 1994 ### `platform.validates` 1995 1996 Get the IDs of the blockchains a Subnet validates. 1997 1998 **Signature:** 1999 2000 ```sh 2001 platform.validates( 2002 { 2003 subnetID: string 2004 } 2005 ) -> {blockchainIDs: []string} 2006 ``` 2007 2008 - `subnetID` is the Subnet’s ID. 2009 - Each element of `blockchainIDs` is the ID of a blockchain the Subnet validates. 2010 2011 **Example Call:** 2012 2013 ```sh 2014 curl -X POST --data '{ 2015 "jsonrpc": "2.0", 2016 "method": "platform.validates", 2017 "params": { 2018 "subnetID":"2bRCr6B4MiEfSjidDwxDpdCyviwnfUVqB2HGwhm947w9YYqb7r" 2019 }, 2020 "id": 1 2021 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P 2022 ``` 2023 2024 **Example Response:** 2025 2026 ```json 2027 { 2028 "jsonrpc": "2.0", 2029 "result": { 2030 "blockchainIDs": [ 2031 "KDYHHKjM4yTJTT8H8qPs5KXzE6gQH5TZrmP1qVr1P6qECj3XN", 2032 "2TtHFqEAAJ6b33dromYMqfgavGPF3iCpdG3hwNMiart2aB5QHi" 2033 ] 2034 }, 2035 "id": 1 2036 } 2037 ```