github.com/MetalBlockchain/metalgo@v1.11.9/vms/avm/service.md (about) 1 --- 2 tags: [X-Chain, AvalancheGo APIs] 3 description: This page is an overview of the Exchange Chain (X-Chain) API associated with AvalancheGo. 4 sidebar_label: API 5 pagination_label: X-Chain API 6 --- 7 8 # X-Chain API 9 10 The [X-Chain](/learn/avalanche/avalanche-platform.md#x-chain), 11 Avalanche’s native platform for creating and trading assets, is an instance of the Avalanche Virtual 12 Machine (AVM). This API allows clients to create and trade assets on the X-Chain and other instances 13 of the AVM. 14 15 ## Format 16 17 This API uses the `json 2.0` RPC format. For more information on making JSON RPC calls, see 18 [here](/reference/standards/guides/issuing-api-calls.md). 19 20 ## Endpoints 21 22 `/ext/bc/X` to interact with the X-Chain. 23 24 `/ext/bc/blockchainID` to interact with other AVM instances, where `blockchainID` is the ID of a 25 blockchain running the AVM. 26 27 ## Methods 28 29 ### `avm.buildGenesis` 30 31 Given a JSON representation of this Virtual Machine’s genesis state, create the byte representation 32 of that state. 33 34 #### **Endpoint** 35 36 This call is made to the AVM’s static API endpoint: 37 38 `/ext/vm/avm` 39 40 Note: addresses should not include a chain prefix (that is `X-`) in calls to the static API endpoint 41 because these prefixes refer to a specific chain. 42 43 **Signature:** 44 45 ```sh 46 avm.buildGenesis({ 47 networkID: int, 48 genesisData: JSON, 49 encoding: string, //optional 50 }) -> { 51 bytes: string, 52 encoding: string, 53 } 54 ``` 55 56 Encoding specifies the encoding format to use for arbitrary bytes, that is the genesis bytes that are 57 returned. Can only be `hex` when a value is provided. 58 59 `genesisData` has this form: 60 61 ```json 62 { 63 "genesisData" : 64 { 65 "assetAlias1": { // Each object defines an asset 66 "name": "human readable name", 67 "symbol":"AVAL", // Symbol is between 0 and 4 characters 68 "initialState": { 69 "fixedCap" : [ // Choose the asset type. 70 { // Can be "fixedCap", "variableCap", "limitedTransfer", "nonFungible" 71 "amount":1000, // At genesis, address A has 72 "address":"A" // 1000 units of asset 73 }, 74 { 75 "amount":5000, // At genesis, address B has 76 "address":"B" // 1000 units of asset 77 }, 78 ... // Can have many initial holders 79 ] 80 } 81 }, 82 "assetAliasCanBeAnythingUnique": { // Asset alias can be used in place of assetID in calls 83 "name": "human readable name", // names need not be unique 84 "symbol": "AVAL", // symbols need not be unique 85 "initialState": { 86 "variableCap" : [ // No units of the asset exist at genesis 87 { 88 "minters": [ // The signature of A or B can mint more of 89 "A", // the asset. 90 "B" 91 ], 92 "threshold":1 93 }, 94 { 95 "minters": [ // The signatures of 2 of A, B and C can mint 96 "A", // more of the asset 97 "B", 98 "C" 99 ], 100 "threshold":2 101 }, 102 ... // Can have many minter sets 103 ] 104 } 105 }, 106 ... // Can list more assets 107 } 108 } 109 ``` 110 111 **Example Call:** 112 113 ```sh 114 curl -X POST --data '{ 115 "jsonrpc": "2.0", 116 "id" : 1, 117 "method" : "avm.buildGenesis", 118 "params" : { 119 "networkId": 16, 120 "genesisData": { 121 "asset1": { 122 "name": "myFixedCapAsset", 123 "symbol":"MFCA", 124 "initialState": { 125 "fixedCap" : [ 126 { 127 "amount":100000, 128 "address": "avax13ery2kvdrkd2nkquvs892gl8hg7mq4a6ufnrn6" 129 }, 130 { 131 "amount":100000, 132 "address": "avax1rvks3vpe4cm9yc0rrk8d5855nd6yxxutfc2h2r" 133 }, 134 { 135 "amount":50000, 136 "address": "avax1ntj922dj4crc4pre4e0xt3dyj0t5rsw9uw0tus" 137 }, 138 { 139 "amount":50000, 140 "address": "avax1yk0xzmqyyaxn26sqceuky2tc2fh2q327vcwvda" 141 } 142 ] 143 } 144 }, 145 "asset2": { 146 "name": "myVarCapAsset", 147 "symbol":"MVCA", 148 "initialState": { 149 "variableCap" : [ 150 { 151 "minters": [ 152 "avax1kcfg6avc94ct3qh2mtdg47thsk8nrflnrgwjqr", 153 "avax14e2s22wxvf3c7309txxpqs0qe9tjwwtk0dme8e" 154 ], 155 "threshold":1 156 }, 157 { 158 "minters": [ 159 "avax1y8pveyn82gjyqr7kqzp72pqym6xlch9gt5grck", 160 "avax1c5cmm0gem70rd8dcnpel63apzfnfxye9kd4wwe", 161 "avax12euam2lwtwa8apvfdl700ckhg86euag2hlhmyw" 162 ], 163 "threshold":2 164 } 165 ] 166 } 167 } 168 }, 169 "encoding": "hex" 170 } 171 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/vm/avm 172 ``` 173 174 **Example Response:** 175 176 ```json 177 { 178 "jsonrpc": "2.0", 179 "result": { 180 "bytes": "0x0000000000010006617373657431000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f6d794669786564436170417373657400044d464341000000000100000000000000010000000700000000000186a10000000000000000000000010000000152b219bc1b9ab0a9f2e3f9216e4460bd5db8d153bfa57c3c", 181 "encoding": "hex" 182 }, 183 "id": 1 184 } 185 ``` 186 187 ### `avm.createAddress` 188 189 :::caution 190 191 Deprecated as of [**v1.9.12**](https://github.com/ava-labs/avalanchego/releases/tag/v1.9.12). 192 193 ::: 194 195 :::warning 196 Not recommended for use on Mainnet. See warning notice in [Keystore API](/reference/avalanchego/keystore-api.md). 197 ::: 198 199 Create a new address controlled by the given user. 200 201 **Signature:** 202 203 ```sh 204 avm.createAddress({ 205 username: string, 206 password: string 207 }) -> {address: string} 208 ``` 209 210 **Example Call:** 211 212 ```sh 213 curl -X POST --data '{ 214 "jsonrpc": "2.0", 215 "method": "avm.createAddress", 216 "params": { 217 "username": "myUsername", 218 "password": "myPassword" 219 }, 220 "id": 1 221 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/X 222 ``` 223 224 **Example Response:** 225 226 ```json 227 { 228 "jsonrpc": "2.0", 229 "result": { 230 "address": "X-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5" 231 }, 232 "id": 1 233 } 234 ``` 235 236 <!-- 237 TODO: Add avm.createAsset 238 --> 239 240 ### `avm.createFixedCapAsset` 241 242 :::caution 243 244 Deprecated as of [**v1.9.12**](https://github.com/ava-labs/avalanchego/releases/tag/v1.9.12). 245 246 ::: 247 248 :::warning 249 Not recommended for use on Mainnet. See warning notice in [Keystore API](/reference/avalanchego/keystore-api.md). 250 ::: 251 252 Create a new fixed-cap, fungible asset. A quantity of it is created at initialization and then no 253 more is ever created. The asset can be sent with `avm.send`. 254 255 **Signature:** 256 257 ```sh 258 avm.createFixedCapAsset({ 259 name: string, 260 symbol: string, 261 denomination: int, //optional 262 initialHolders: []{ 263 address: string, 264 amount: int 265 }, 266 from: []string, //optional 267 changeAddr: string, //optional 268 username: string, 269 password: string 270 }) -> 271 { 272 assetID: string, 273 changeAddr: string 274 } 275 ``` 276 277 - `name` is a human-readable name for the asset. Not necessarily unique. 278 - `symbol` is a shorthand symbol for the asset. Between 0 and 4 characters. Not necessarily unique. 279 May be omitted. 280 - `denomination` determines how balances of this asset are displayed by user interfaces. If 281 `denomination` is 0, 100 units of this asset are displayed as 100. If `denomination` is 1, 100 282 units of this asset are displayed as 10.0. If `denomination` is 2, 100 units of this asset are 283 displayed as 1.00, etc. Defaults to 0. 284 - `from` are the addresses that you want to use for this operation. If omitted, uses any of your 285 addresses as needed. 286 - `changeAddr` is the address any change will be sent to. If omitted, change is sent to one of the 287 addresses controlled by the user. 288 - `username` and `password` denote the user paying the transaction fee. 289 - Each element in `initialHolders` specifies that `address` holds `amount` units of the asset at 290 genesis. 291 - `assetID` is the ID of the new asset. 292 293 **Example Call:** 294 295 ```sh 296 curl -X POST --data '{ 297 "jsonrpc":"2.0", 298 "id" : 1, 299 "method" :"avm.createFixedCapAsset", 300 "params" :{ 301 "name": "myFixedCapAsset", 302 "symbol":"MFCA", 303 "initialHolders": [ 304 { 305 "address": "X-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5", 306 "amount": 10000 307 }, 308 { 309 "address":"X-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5", 310 "amount":50000 311 } 312 ], 313 "from":["X-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5"], 314 "changeAddr":"X-avax1turszjwn05lflpewurw96rfrd3h6x8flgs5uf8", 315 "username":"myUsername", 316 "password":"myPassword" 317 } 318 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/X 319 ``` 320 321 **Example Response:** 322 323 ```json 324 { 325 "jsonrpc": "2.0", 326 "id": 1, 327 "result": { 328 "assetID": "ZiKfqRXCZgHLgZ4rxGU9Qbycdzuq5DRY4tdSNS9ku8kcNxNLD", 329 "changeAddr": "X-avax1turszjwn05lflpewurw96rfrd3h6x8flgs5uf8" 330 } 331 } 332 ``` 333 334 ### `avm.createNFTAsset` 335 336 :::caution 337 338 Deprecated as of [**v1.9.12**](https://github.com/ava-labs/avalanchego/releases/tag/v1.9.12). 339 340 ::: 341 342 :::warning 343 Not recommended for use on Mainnet. See warning notice in [Keystore API](/reference/avalanchego/keystore-api.md). 344 ::: 345 346 Create a new non-fungible asset. No units of the asset exist at initialization. Minters can mint 347 units of this asset using `avm.mintNFT`. 348 349 **Signature:** 350 351 ```sh 352 avm.createNFTAsset({ 353 name: string, 354 symbol: string, 355 minterSets: []{ 356 minters: []string, 357 threshold: int 358 }, 359 from: []string, //optional 360 changeAddr: string, //optional 361 username: string, 362 password: string 363 }) -> 364 { 365 assetID: string, 366 changeAddr: string, 367 } 368 ``` 369 370 - `name` is a human-readable name for the asset. Not necessarily unique. 371 - `symbol` is a shorthand symbol for the asset. Between 0 and 4 characters. Not necessarily unique. 372 May be omitted. 373 - `minterSets` is a list where each element specifies that `threshold` of the addresses in `minters` 374 may together mint more of the asset by signing a minting transaction. 375 - `from` are the addresses that you want to use for this operation. If omitted, uses any of your 376 addresses as needed. 377 - `changeAddr` is the address any change will be sent to. If omitted, change is sent to one of the 378 addresses controlled by the user. 379 - `username` pays the transaction fee. 380 - `assetID` is the ID of the new asset. 381 - `changeAddr` in the result is the address where any change was sent. 382 383 **Example Call:** 384 385 ```sh 386 curl -X POST --data '{ 387 "jsonrpc":"2.0", 388 "id" : 1, 389 "method" :"avm.createNFTAsset", 390 "params" :{ 391 "name":"Coincert", 392 "symbol":"TIXX", 393 "minterSets":[ 394 { 395 "minters":[ 396 "X-avax1turszjwn05lflpewurw96rfrd3h6x8flgs5uf8" 397 ], 398 "threshold": 1 399 } 400 ], 401 "from": ["X-avax1turszjwn05lflpewurw96rfrd3h6x8flgs5uf8"], 402 "changeAddr": "X-avax1turszjwn05lflpewurw96rfrd3h6x8flgs5uf8", 403 "username":"myUsername", 404 "password":"myPassword" 405 } 406 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/X 407 ``` 408 409 **Example Response:** 410 411 ```json 412 { 413 "jsonrpc": "2.0", 414 "result": { 415 "assetID": "2KGdt2HpFKpTH5CtGZjYt5XPWs6Pv9DLoRBhiFfntbezdRvZWP", 416 "changeAddr": "X-avax1turszjwn05lflpewurw96rfrd3h6x8flgs5uf8" 417 }, 418 "id": 1 419 } 420 ``` 421 422 ### `avm.createVariableCapAsset` 423 424 :::caution 425 426 Deprecated as of [**v1.9.12**](https://github.com/ava-labs/avalanchego/releases/tag/v1.9.12). 427 428 ::: 429 430 :::warning 431 Not recommended for use on Mainnet. See warning notice in [Keystore API](/reference/avalanchego/keystore-api.md). 432 ::: 433 434 Create a new variable-cap, fungible asset. No units of the asset exist at initialization. Minters 435 can mint units of this asset using `avm.mint`. 436 437 **Signature:** 438 439 ```sh 440 avm.createVariableCapAsset({ 441 name: string, 442 symbol: string, 443 denomination: int, //optional 444 minterSets: []{ 445 minters: []string, 446 threshold: int 447 }, 448 from: []string, //optional 449 changeAddr: string, //optional 450 username: string, 451 password: string 452 }) -> 453 { 454 assetID: string, 455 changeAddr: string, 456 } 457 ``` 458 459 - `name` is a human-readable name for the asset. Not necessarily unique. 460 - `symbol` is a shorthand symbol for the asset. Between 0 and 4 characters. Not necessarily unique. 461 May be omitted. 462 - `denomination` determines how balances of this asset are displayed by user interfaces. If 463 denomination is 0, 100 units of this asset are displayed as 100. If denomination is 1, 100 units 464 of this asset are displayed as 10.0. If denomination is 2, 100 units of this asset are displays as 465 .100, etc. 466 - `minterSets` is a list where each element specifies that `threshold` of the addresses in `minters` 467 may together mint more of the asset by signing a minting transaction. 468 - `from` are the addresses that you want to use for this operation. If omitted, uses any of your 469 addresses as needed. 470 - `changeAddr` is the address any change will be sent to. If omitted, change is sent to one of the 471 addresses controlled by the user. 472 - `username` pays the transaction fee. 473 - `assetID` is the ID of the new asset. 474 - `changeAddr` in the result is the address where any change was sent. 475 476 **Example Call:** 477 478 ```sh 479 curl -X POST --data '{ 480 "jsonrpc":"2.0", 481 "id" : 1, 482 "method" :"avm.createVariableCapAsset", 483 "params" :{ 484 "name":"myVariableCapAsset", 485 "symbol":"MFCA", 486 "minterSets":[ 487 { 488 "minters":[ 489 "X-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5" 490 ], 491 "threshold": 1 492 }, 493 { 494 "minters": [ 495 "X-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5", 496 "X-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5", 497 "X-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5" 498 ], 499 "threshold": 2 500 } 501 ], 502 "from":["X-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5"], 503 "changeAddr":"X-avax1turszjwn05lflpewurw96rfrd3h6x8flgs5uf8", 504 "username":"myUsername", 505 "password":"myPassword" 506 } 507 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/X 508 ``` 509 510 **Example Response:** 511 512 ```json 513 { 514 "jsonrpc": "2.0", 515 "id": 1, 516 "result": { 517 "assetID": "2QbZFE7J4MAny9iXHUwq8Pz8SpFhWk3maCw4SkinVPv6wPmAbK", 518 "changeAddr": "X-avax1turszjwn05lflpewurw96rfrd3h6x8flgs5uf8" 519 } 520 } 521 ``` 522 523 ### `avm.export` 524 525 :::caution 526 527 Deprecated as of [**v1.9.12**](https://github.com/ava-labs/avalanchego/releases/tag/v1.9.12). 528 529 ::: 530 531 ::: 532 Not recommended for use on Mainnet. See warning notice in [Keystore API](/reference/avalanchego/keystore-api.md). 533 ::: 534 535 Send an asset from the X-Chain to the P-Chain or C-Chain. 536 537 **Signature:** 538 539 ```sh 540 avm.export({ 541 to: string, 542 amount: int, 543 assetID: string, 544 from: []string, //optional 545 changeAddr: string, //optional 546 username: string, 547 password: string, 548 }) -> 549 { 550 txID: string, 551 changeAddr: string, 552 } 553 ``` 554 555 - `to` is the P-Chain or C-Chain address the asset is sent to. 556 - `amount` is the amount of the asset to send. 557 - `assetID` is the asset id of the asset which is sent. Use `AVAX` for AVAX exports. 558 - `from` are the addresses that you want to use for this operation. If omitted, uses any of your 559 addresses as needed. 560 - `changeAddr` is the address any change will be sent to. If omitted, change is sent to one of the 561 addresses controlled by the user. 562 - The asset is sent from addresses controlled by `username` 563 - `password` is `username`‘s password. 564 565 - `txID` is this transaction’s ID. 566 - `changeAddr` in the result is the address where any change was sent. 567 568 **Example Call:** 569 570 ```sh 571 curl -X POST --data '{ 572 "jsonrpc":"2.0", 573 "id" :1, 574 "method" :"avm.export", 575 "params" :{ 576 "to":"C-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5", 577 "amount": 10, 578 "assetID": "AVAX", 579 "from":["X-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5"], 580 "changeAddr":"X-avax1turszjwn05lflpewurw96rfrd3h6x8flgs5uf8", 581 "username":"myUsername", 582 "password":"myPassword" 583 } 584 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/X 585 ``` 586 587 **Example Response:** 588 589 ```json 590 { 591 "jsonrpc": "2.0", 592 "result": { 593 "txID": "2Eu16yNaepP57XrrJgjKGpiEDandpiGWW8xbUm6wcTYny3fejj", 594 "changeAddr": "X-avax1turszjwn05lflpewurw96rfrd3h6x8flgs5uf8" 595 }, 596 "id": 1 597 } 598 ``` 599 600 <!-- 601 TODO: Add avm.exportAVAX 602 --> 603 604 ### `avm.exportKey` 605 606 :::caution 607 608 Deprecated as of [**v1.9.12**](https://github.com/ava-labs/avalanchego/releases/tag/v1.9.12). 609 610 ::: 611 612 :::warning 613 Not recommended for use on Mainnet. See warning notice in [Keystore API](/reference/avalanchego/keystore-api.md). 614 ::: 615 616 Get the private key that controls a given address. The returned private key can be added to a user 617 with [`avm.importKey`](/reference/avalanchego/x-chain/api.md#avmimportkey). 618 619 **Signature:** 620 621 ```sh 622 avm.exportKey({ 623 username: string, 624 password: string, 625 address: string 626 }) -> {privateKey: string} 627 ``` 628 629 - `username` must control `address`. 630 - `privateKey` is the string representation of the private key that controls `address`. 631 632 **Example Call:** 633 634 ```sh 635 curl -X POST --data '{ 636 "jsonrpc":"2.0", 637 "id" :1, 638 "method" :"avm.exportKey", 639 "params" :{ 640 "username":"myUsername", 641 "password":"myPassword", 642 "address":"X-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5" 643 } 644 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/X 645 ``` 646 647 **Example Response:** 648 649 ```json 650 { 651 "jsonrpc": "2.0", 652 "id": 1, 653 "result": { 654 "privateKey": "PrivateKey-2w4XiXxPfQK4TypYqnohRL8DRNTz9cGiGmwQ1zmgEqD9c9KWLq" 655 } 656 } 657 ``` 658 659 ### `avm.getAddressTxs` 660 661 :::caution 662 663 Deprecated as of [**v1.9.12**](https://github.com/ava-labs/avalanchego/releases/tag/v1.9.12). 664 665 ::: 666 667 Returns all transactions that change the balance of the given address. A transaction is said to 668 change an address's balance if either is true: 669 670 - A UTXO that the transaction consumes was at least partially owned by the address. 671 - A UTXO that the transaction produces is at least partially owned by the address. 672 673 :::tip 674 Note: Indexing (`index-transactions`) must be enabled in the X-chain config. 675 ::: 676 677 **Signature:** 678 679 ```sh 680 avm.getAddressTxs({ 681 address: string, 682 cursor: uint64, // optional, leave empty to get the first page 683 assetID: string, 684 pageSize: uint64 // optional, defaults to 1024 685 }) -> { 686 txIDs: []string, 687 cursor: uint64, 688 } 689 ``` 690 691 **Request Parameters:** 692 693 - `address`: The address for which we're fetching related transactions 694 - `assetID`: Only return transactions that changed the balance of this asset. Must be an ID or an 695 alias for an asset. 696 - `pageSize`: Number of items to return per page. Optional. Defaults to 1024. 697 698 **Response Parameter:** 699 700 - `txIDs`: List of transaction IDs that affected the balance of this address. 701 - `cursor`: Page number or offset. Use this in request to get the next page. 702 703 **Example Call:** 704 705 ```sh 706 curl -X POST --data '{ 707 "jsonrpc":"2.0", 708 "id" : 1, 709 "method" :"avm.getAddressTxs", 710 "params" :{ 711 "address":"X-local1kpprmfpzzm5lxyene32f6lr7j0aj7gxsu6hp9y", 712 "assetID":"AVAX", 713 "pageSize":20 714 } 715 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/X 716 ``` 717 718 **Example Response:** 719 720 ```json 721 { 722 "jsonrpc": "2.0", 723 "result": { 724 "txIDs": ["SsJF7KKwxiUJkczygwmgLqo3XVRotmpKP8rMp74cpLuNLfwf6"], 725 "cursor": "1" 726 }, 727 "id": 1 728 } 729 ``` 730 731 ### `avm.getAllBalances` 732 733 :::caution 734 735 Deprecated as of [**v1.9.12**](https://github.com/ava-labs/avalanchego/releases/tag/v1.9.12). 736 737 ::: 738 739 Get the balances of all assets controlled by a given address. 740 741 **Signature:** 742 743 ```sh 744 avm.getAllBalances({address:string}) -> { 745 balances: []{ 746 asset: string, 747 balance: int 748 } 749 } 750 ``` 751 752 **Example Call:** 753 754 ```sh 755 curl -X POST --data '{ 756 "jsonrpc":"2.0", 757 "id" : 1, 758 "method" :"avm.getAllBalances", 759 "params" :{ 760 "address":"X-avax1c79e0dd0susp7dc8udq34jgk2yvve7hapvdyht" 761 } 762 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/X 763 ``` 764 765 **Example Response:** 766 767 ```json 768 { 769 "jsonrpc": "2.0", 770 "result": { 771 "balances": [ 772 { 773 "asset": "AVAX", 774 "balance": "102" 775 }, 776 { 777 "asset": "2sdnziCz37Jov3QSNMXcFRGFJ1tgauaj6L7qfk7yUcRPfQMC79", 778 "balance": "10000" 779 } 780 ] 781 }, 782 "id": 1 783 } 784 ``` 785 786 ### `avm.getAssetDescription` 787 788 Get information about an asset. 789 790 **Signature:** 791 792 ```sh 793 avm.getAssetDescription({assetID: string}) -> { 794 assetId: string, 795 name: string, 796 symbol: string, 797 denomination: int 798 } 799 ``` 800 801 - `assetID` is the id of the asset for which the information is requested. 802 - `name` is the asset’s human-readable, not necessarily unique name. 803 - `symbol` is the asset’s symbol. 804 - `denomination` determines how balances of this asset are displayed by user interfaces. If 805 denomination is 0, 100 units of this asset are displayed as 100. If denomination is 1, 100 units 806 of this asset are displayed as 10.0. If denomination is 2, 100 units of this asset are displays as 807 .100, etc. 808 809 :::note 810 811 The AssetID for AVAX differs depending on the network you are on. 812 813 Mainnet: FvwEAhmxKfeiG8SnEvq42hc6whRyY3EFYAvebMqDNDGCgxN5Z 814 815 Testnet: U8iRqJoiJm8xZHAacmvYyZVwqQx6uDNtQeP3CQ6fcgQk3JqnK 816 817 For finding the `assetID` of other assets, this [info] might be useful. 818 Also, `avm.getUTXOs` returns the `assetID` in its output. 819 820 ::: 821 822 **Example Call:** 823 824 ```sh 825 curl -X POST --data '{ 826 "jsonrpc":"2.0", 827 "id" :1, 828 "method" :"avm.getAssetDescription", 829 "params" :{ 830 "assetID" :"FvwEAhmxKfeiG8SnEvq42hc6whRyY3EFYAvebMqDNDGCgxN5Z" 831 } 832 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/X 833 ``` 834 835 **Example Response:** 836 837 ```json 838 { 839 "jsonrpc": "2.0", 840 "result": { 841 "assetID": "FvwEAhmxKfeiG8SnEvq42hc6whRyY3EFYAvebMqDNDGCgxN5Z", 842 "name": "Avalanche", 843 "symbol": "AVAX", 844 "denomination": "9" 845 }, 846 "id": 1 847 }` 848 ``` 849 850 ### `avm.getBalance` 851 852 :::caution 853 854 Deprecated as of [**v1.9.12**](https://github.com/ava-labs/avalanchego/releases/tag/v1.9.12). 855 856 ::: 857 858 Get the balance of an asset controlled by a given address. 859 860 **Signature:** 861 862 ```sh 863 avm.getBalance({ 864 address: string, 865 assetID: string 866 }) -> {balance: int} 867 ``` 868 869 - `address` owner of the asset 870 - `assetID` id of the asset for which the balance is requested 871 872 **Example Call:** 873 874 ```sh 875 curl -X POST --data '{ 876 "jsonrpc":"2.0", 877 "id" : 1, 878 "method" :"avm.getBalance", 879 "params" :{ 880 "address":"X-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5", 881 "assetID": "2pYGetDWyKdHxpFxh2LHeoLNCH6H5vxxCxHQtFnnFaYxLsqtHC" 882 } 883 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/X 884 ``` 885 886 **Example Response:** 887 888 ```json 889 { 890 "jsonrpc": "2.0", 891 "id": 1, 892 "result": { 893 "balance": "299999999999900", 894 "utxoIDs": [ 895 { 896 "txID": "WPQdyLNqHfiEKp4zcCpayRHYDVYuh1hqs9c1RqgZXS4VPgdvo", 897 "outputIndex": 1 898 } 899 ] 900 } 901 } 902 ``` 903 904 ### `avm.getBlock` 905 906 Returns the block with the given id. 907 908 **Signature:** 909 910 ```sh 911 avm.getBlock({ 912 blockID: string 913 encoding: string // optional 914 }) -> { 915 block: string, 916 encoding: string 917 } 918 ``` 919 920 **Request:** 921 922 - `blockID` is the block ID. It should be in cb58 format. 923 - `encoding` is the encoding format to use. Can be either `hex` or `json`. Defaults to `hex`. 924 925 **Response:** 926 927 - `block` is the transaction encoded to `encoding`. 928 - `encoding` is the `encoding`. 929 930 #### Hex Example 931 932 **Example Call:** 933 934 ```sh 935 curl -X POST --data '{ 936 "jsonrpc": "2.0", 937 "method": "avm.getBlock", 938 "params": { 939 "blockID": "tXJ4xwmR8soHE6DzRNMQPtiwQvuYsHn6eLLBzo2moDqBquqy6", 940 "encoding": "hex" 941 }, 942 "id": 1 943 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/X 944 ``` 945 946 **Example Response:** 947 948 ```json 949 { 950 "jsonrpc": "2.0", 951 "result": { 952 "block": "0x00000000002000000000641ad33ede17f652512193721df87994f783ec806bb5640c39ee73676caffcc3215e0651000000000049a80a000000010000000e0000000100000000000000000000000000000000000000000000000000000000000000000000000121e67317cbc4be2aeb00677ad6462778a8f52274b9d605df2591b23027a87dff000000070000002e1a2a3910000000000000000000000001000000015cf998275803a7277926912defdf177b2e97b0b400000001e0d825c5069a7336671dd27eaa5c7851d2cf449e7e1cdc469c5c9e5a953955950000000021e67317cbc4be2aeb00677ad6462778a8f52274b9d605df2591b23027a87dff000000050000008908223b680000000100000000000000005e45d02fcc9e585544008f1df7ae5c94bf7f0f2600000000641ad3b600000000642d48b60000005aedf802580000000121e67317cbc4be2aeb00677ad6462778a8f52274b9d605df2591b23027a87dff000000070000005aedf80258000000000000000000000001000000015cf998275803a7277926912defdf177b2e97b0b40000000b000000000000000000000001000000012892441ba9a160bcdc596dcd2cc3ad83c3493589000000010000000900000001adf2237a5fe2dfd906265e8e14274aa7a7b2ee60c66213110598ba34fb4824d74f7760321c0c8fb1e8d3c5e86909248e48a7ae02e641da5559351693a8a1939800286d4fa2", 953 "encoding": "hex" 954 }, 955 "id": 1 956 } 957 ``` 958 959 ### `avm.getBlockByHeight` 960 961 Returns block at the given height. 962 963 **Signature:** 964 965 ```sh 966 avm.getBlockByHeight({ 967 height: string 968 encoding: string // optional 969 }) -> { 970 block: string, 971 encoding: string 972 } 973 ``` 974 975 **Request:** 976 977 - `blockHeight` is the block height. It should be in `string` format. 978 - `encoding` is the encoding format to use. Can be either `hex` or `json`. Defaults to `hex`. 979 980 **Response:** 981 982 - `block` is the transaction encoded to `encoding`. 983 - `encoding` is the `encoding`. 984 985 #### Hex Example 986 987 **Example Call:** 988 989 ```sh 990 curl -X POST --data '{ 991 "jsonrpc": "2.0", 992 "method": "avm.getBlockByHeight”, 993 "params": { 994 “height”: “275686313486”, 995 "encoding": “hex” 996 }, 997 "id": 1 998 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/X 999 ``` 1000 1001 **Example Response:** 1002 1003 ```json 1004 { 1005 "jsonrpc": "2.0", 1006 "result": { 1007 "block": "0x00000000002000000000642f6739d4efcdd07e4d4919a7fc2020b8a0f081dd64c262aaace5a6dad22be0b55fec0700000000004db9e100000001000000110000000100000000000000000000000000000000000000000000000000000000000000000000000121e67317cbc4be2aeb00677ad6462778a8f52274b9d605df2591b23027a87dff000000070000005c6ece390000000000000000000000000100000001930ab7bf5018bfc6f9435c8b15ba2fe1e619c0230000000000000000ed5f38341e436e5d46e2bb00b45d62ae97d1b050c64bc634ae10626739e35c4b00000001c6dda861341665c3b555b46227fb5e56dc0a870c5482809349f04b00348af2a80000000021e67317cbc4be2aeb00677ad6462778a8f52274b9d605df2591b23027a87dff000000050000005c6edd7b40000000010000000000000001000000090000000178688f4d5055bd8733801f9b52793da885bef424c90526c18e4dd97f7514bf6f0c3d2a0e9a5ea8b761bc41902eb4902c34ef034c4d18c3db7c83c64ffeadd93600731676de", 1008 "encoding": "hex" 1009 }, 1010 "id": 1 1011 } 1012 ``` 1013 1014 ### `avm.getHeight` 1015 1016 Returns the height of the last accepted block. 1017 1018 **Signature:** 1019 1020 ```sh 1021 avm.getHeight() -> 1022 { 1023 height: uint64, 1024 } 1025 ``` 1026 1027 **Example Call:** 1028 1029 ```sh 1030 curl -X POST --data '{ 1031 "jsonrpc": "2.0", 1032 "method": "avm.getHeight", 1033 "params": {}, 1034 "id": 1 1035 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/X 1036 ``` 1037 1038 **Example Response:** 1039 1040 ```json 1041 { 1042 "jsonrpc": "2.0", 1043 "result": { 1044 "height": "5094088" 1045 }, 1046 "id": 1 1047 } 1048 ``` 1049 1050 ### `avm.getTx` 1051 1052 Returns the specified transaction. The `encoding` parameter sets the format of the returned 1053 transaction. Can be either `"hex"` or `"json"`. Defaults to `"hex"`. 1054 1055 **Signature:** 1056 1057 ```sh 1058 avm.getTx({ 1059 txID: string, 1060 encoding: string, //optional 1061 }) -> { 1062 tx: string, 1063 encoding: string, 1064 } 1065 ``` 1066 1067 **Example Call:** 1068 1069 ```sh 1070 curl -X POST --data '{ 1071 "jsonrpc":"2.0", 1072 "id" :1, 1073 "method" :"avm.getTx", 1074 "params" :{ 1075 "txID":"2oJCbb8pfdxEHAf9A8CdN4Afj9VSR3xzyzNkf8tDv7aM1sfNFL", 1076 "encoding": "json" 1077 } 1078 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/X 1079 ``` 1080 1081 **Example Response:** 1082 1083 ```json 1084 { 1085 "jsonrpc": "2.0", 1086 "result": { 1087 "tx": { 1088 "unsignedTx": { 1089 "networkID": 1, 1090 "blockchainID": "2oYMBNV4eNHyqk2fjjV5nVQLDbtmNJzq5s3qs3Lo6ftnC6FByM", 1091 "outputs": [], 1092 "inputs": [ 1093 { 1094 "txID": "2jbZUvi6nHy3Pgmk8xcMpSg5cW6epkPqdKkHSCweb4eRXtq4k9", 1095 "outputIndex": 1, 1096 "assetID": "FvwEAhmxKfeiG8SnEvq42hc6whRyY3EFYAvebMqDNDGCgxN5Z", 1097 "fxID": "spdxUxVJQbX85MGxMHbKw1sHxMnSqJ3QBzDyDYEP3h6TLuxqQ", 1098 "input": { 1099 "amount": 2570382395, 1100 "signatureIndices": [0] 1101 } 1102 } 1103 ], 1104 "memo": "0x", 1105 "destinationChain": "11111111111111111111111111111111LpoYY", 1106 "exportedOutputs": [ 1107 { 1108 "assetID": "FvwEAhmxKfeiG8SnEvq42hc6whRyY3EFYAvebMqDNDGCgxN5Z", 1109 "fxID": "spdxUxVJQbX85MGxMHbKw1sHxMnSqJ3QBzDyDYEP3h6TLuxqQ", 1110 "output": { 1111 "addresses": ["X-avax1tnuesf6cqwnjw7fxjyk7lhch0vhf0v95wj5jvy"], 1112 "amount": 2569382395, 1113 "locktime": 0, 1114 "threshold": 1 1115 } 1116 } 1117 ] 1118 }, 1119 "credentials": [ 1120 { 1121 "fxID": "spdxUxVJQbX85MGxMHbKw1sHxMnSqJ3QBzDyDYEP3h6TLuxqQ", 1122 "credential": { 1123 "signatures": [ 1124 "0x46ebcbcfbee3ece1fd15015204045cf3cb77f42c48d0201fc150341f91f086f177cfca8894ca9b4a0c55d6950218e4ea8c01d5c4aefb85cd7264b47bd57d224400" 1125 ] 1126 } 1127 } 1128 ], 1129 "id": "2oJCbb8pfdxEHAf9A8CdN4Afj9VSR3xzyzNkf8tDv7aM1sfNFL" 1130 }, 1131 "encoding": "json" 1132 }, 1133 "id": 1 1134 } 1135 ``` 1136 1137 Where: 1138 1139 - `credentials` is a list of this transaction's credentials. Each credential proves that this 1140 transaction's creator is allowed to consume one of this transaction's inputs. Each credential is a 1141 list of signatures. 1142 - `unsignedTx` is the non-signature portion of the transaction. 1143 - `networkID` is the ID of the network this transaction happened on. (Avalanche Mainnet is `1`.) 1144 - `blockchainID` is the ID of the blockchain this transaction happened on. (Avalanche Mainnet 1145 X-Chain is `2oYMBNV4eNHyqk2fjjV5nVQLDbtmNJzq5s3qs3Lo6ftnC6FByM`.) 1146 - Each element of `outputs` is an output (UTXO) of this transaction that is not being exported to 1147 another chain. 1148 - Each element of `inputs` is an input of this transaction which has not been imported from another 1149 chain. 1150 - Import Transactions have additional fields `sourceChain` and `importedInputs`, which specify the 1151 blockchain ID that assets are being imported from, and the inputs that are being imported. 1152 - Export Transactions have additional fields `destinationChain` and `exportedOutputs`, which specify 1153 the blockchain ID that assets are being exported to, and the UTXOs that are being exported. 1154 1155 An output contains: 1156 1157 - `assetID`: The ID of the asset being transferred. (The Mainnet Avax ID is 1158 `FvwEAhmxKfeiG8SnEvq42hc6whRyY3EFYAvebMqDNDGCgxN5Z`.) 1159 - `fxID`: The ID of the FX this output uses. 1160 - `output`: The FX-specific contents of this output. 1161 1162 Most outputs use the secp256k1 FX, look like this: 1163 1164 ```json 1165 { 1166 "assetID": "FvwEAhmxKfeiG8SnEvq42hc6whRyY3EFYAvebMqDNDGCgxN5Z", 1167 "fxID": "spdxUxVJQbX85MGxMHbKw1sHxMnSqJ3QBzDyDYEP3h6TLuxqQ", 1168 "output": { 1169 "addresses": ["X-avax126rd3w35xwkmj8670zvf7y5r8k36qa9z9803wm"], 1170 "amount": 1530084210, 1171 "locktime": 0, 1172 "threshold": 1 1173 } 1174 } 1175 ``` 1176 1177 The above output can be consumed after Unix time `locktime` by a transaction that has signatures 1178 from `threshold` of the addresses in `addresses`. 1179 1180 ### `avm.getTxStatus` 1181 1182 :::caution 1183 Deprecated as of **v1.10.0**. 1184 ::: 1185 1186 Get the status of a transaction sent to the network. 1187 1188 **Signature:** 1189 1190 ```sh 1191 avm.getTxStatus({txID: string}) -> {status: string} 1192 ``` 1193 1194 `status` is one of: 1195 1196 - `Accepted`: The transaction is (or will be) accepted by every node 1197 - `Processing`: The transaction is being voted on by this node 1198 - `Rejected`: The transaction will never be accepted by any node in the network 1199 - `Unknown`: The transaction hasn’t been seen by this node 1200 1201 **Example Call:** 1202 1203 ```sh 1204 curl -X POST --data '{ 1205 "jsonrpc":"2.0", 1206 "id" :1, 1207 "method" :"avm.getTxStatus", 1208 "params" :{ 1209 "txID":"2QouvFWUbjuySRxeX5xMbNCuAaKWfbk5FeEa2JmoF85RKLk2dD" 1210 } 1211 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/X 1212 ``` 1213 1214 **Example Response:** 1215 1216 ```json 1217 { 1218 "jsonrpc": "2.0", 1219 "id": 1, 1220 "result": { 1221 "status": "Accepted" 1222 } 1223 } 1224 ``` 1225 1226 ### `avm.getUTXOs` 1227 1228 Gets the UTXOs that reference a given address. If `sourceChain` is specified, then it will retrieve 1229 the atomic UTXOs exported from that chain to the X Chain. 1230 1231 **Signature:** 1232 1233 ```sh 1234 avm.getUTXOs({ 1235 addresses: []string, 1236 limit: int, //optional 1237 startIndex: { //optional 1238 address: string, 1239 utxo: string 1240 }, 1241 sourceChain: string, //optional 1242 encoding: string //optional 1243 }) -> { 1244 numFetched: int, 1245 utxos: []string, 1246 endIndex: { 1247 address: string, 1248 utxo: string 1249 }, 1250 sourceChain: string, //optional 1251 encoding: string 1252 } 1253 ``` 1254 1255 - `utxos` is a list of UTXOs such that each UTXO references at least one address in `addresses`. 1256 - At most `limit` UTXOs are returned. If `limit` is omitted or greater than 1024, it is set to 1024. 1257 - This method supports pagination. `endIndex` denotes the last UTXO returned. To get the next set of 1258 UTXOs, use the value of `endIndex` as `startIndex` in the next call. 1259 - If `startIndex` is omitted, will fetch all UTXOs up to `limit`. 1260 - When using pagination (when `startIndex` is provided), UTXOs are not guaranteed to be unique 1261 across multiple calls. That is, a UTXO may appear in the result of the first call, and then again 1262 in the second call. 1263 - When using pagination, consistency is not guaranteed across multiple calls. That is, the UTXO set 1264 of the addresses may have changed between calls. 1265 - `encoding` sets the format for the returned UTXOs. Can only be `hex` when a value is provided. 1266 1267 #### **Example** 1268 1269 Suppose we want all UTXOs that reference at least one of 1270 `X-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5` and `X-avax1d09qn852zcy03sfc9hay2llmn9hsgnw4tp3dv6`. 1271 1272 ```sh 1273 curl -X POST --data '{ 1274 "jsonrpc":"2.0", 1275 "id" :1, 1276 "method" :"avm.getUTXOs", 1277 "params" :{ 1278 "addresses":["X-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5", "X-avax1d09qn852zcy03sfc9hay2llmn9hsgnw4tp3dv6"], 1279 "limit":5, 1280 "encoding": "hex" 1281 } 1282 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/X 1283 ``` 1284 1285 This gives response: 1286 1287 ```json 1288 { 1289 "jsonrpc": "2.0", 1290 "result": { 1291 "numFetched": "5", 1292 "utxos": [ 1293 "0x0000a195046108a85e60f7a864bb567745a37f50c6af282103e47cc62f036cee404700000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f216c1f01765", 1294 "0x0000ae8b1b94444eed8de9a81b1222f00f1b4133330add23d8ac288bffa98b85271100000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f216473d042a", 1295 "0x0000731ce04b1feefa9f4291d869adc30a33463f315491e164d89be7d6d2d7890cfc00000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f21600dd3047", 1296 "0x0000b462030cc4734f24c0bc224cf0d16ee452ea6b67615517caffead123ab4fbf1500000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f216c71b387e", 1297 "0x000054f6826c39bc957c0c6d44b70f961a994898999179cc32d21eb09c1908d7167b00000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f2166290e79d" 1298 ], 1299 "endIndex": { 1300 "address": "X-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5", 1301 "utxo": "kbUThAUfmBXUmRgTpgD6r3nLj7rJUGho6xyht5nouNNypH45j" 1302 }, 1303 "encoding": "hex" 1304 }, 1305 "id": 1 1306 } 1307 ``` 1308 1309 Since `numFetched` is the same as `limit`, we can tell that there may be more UTXOs that were not 1310 fetched. We call the method again, this time with `startIndex`: 1311 1312 ```sh 1313 curl -X POST --data '{ 1314 "jsonrpc":"2.0", 1315 "id" :2, 1316 "method" :"avm.getUTXOs", 1317 "params" :{ 1318 "addresses":["X-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5"], 1319 "limit":5, 1320 "startIndex": { 1321 "address": "X-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5", 1322 "utxo": "kbUThAUfmBXUmRgTpgD6r3nLj7rJUGho6xyht5nouNNypH45j" 1323 }, 1324 "encoding": "hex" 1325 } 1326 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/X 1327 ``` 1328 1329 This gives response: 1330 1331 ```json 1332 { 1333 "jsonrpc": "2.0", 1334 "result": { 1335 "numFetched": "4", 1336 "utxos": [ 1337 "0x000020e182dd51ee4dcd31909fddd75bb3438d9431f8e4efce86a88a684f5c7fa09300000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f21662861d59", 1338 "0x0000a71ba36c475c18eb65dc90f6e85c4fd4a462d51c5de3ac2cbddf47db4d99284e00000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f21665f6f83f", 1339 "0x0000925424f61cb13e0fbdecc66e1270de68de9667b85baa3fdc84741d048daa69fa00000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f216afecf76a", 1340 "0x000082f30327514f819da6009fad92b5dba24d27db01e29ad7541aa8e6b6b554615c00000000345aa98e8a990f4101e2268fab4c4e1f731c8dfbcffa3a77978686e6390d624f000000070000000000000001000000000000000000000001000000018ba98dabaebcd83056799841cfbc567d8b10f216779c2d59" 1341 ], 1342 "endIndex": { 1343 "address": "X-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5", 1344 "utxo": "21jG2RfqyHUUgkTLe2tUp6ETGLriSDTW3th8JXFbPRNiSZ11jK" 1345 }, 1346 "encoding": "hex" 1347 }, 1348 "id": 1 1349 } 1350 ``` 1351 1352 Since `numFetched` is less than `limit`, we know that we are done fetching UTXOs and don’t need to 1353 call this method again. 1354 1355 Suppose we want to fetch the UTXOs exported from the P Chain to the X Chain in order to build an 1356 ImportTx. Then we need to call GetUTXOs with the `sourceChain` argument in order to retrieve the 1357 atomic UTXOs: 1358 1359 ```sh 1360 curl -X POST --data '{ 1361 "jsonrpc":"2.0", 1362 "id" :1, 1363 "method" :"avm.getUTXOs", 1364 "params" :{ 1365 "addresses":["X-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5", "X-avax1d09qn852zcy03sfc9hay2llmn9hsgnw4tp3dv6"], 1366 "limit":5, 1367 "sourceChain": "P", 1368 "encoding": "hex" 1369 } 1370 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/X 1371 ``` 1372 1373 This gives response: 1374 1375 ```json 1376 { 1377 "jsonrpc": "2.0", 1378 "result": { 1379 "numFetched": "1", 1380 "utxos": [ 1381 "0x00001f989ffaf18a18a59bdfbf209342aa61c6a62a67e8639d02bb3c8ddab315c6fa0000000039c33a499ce4c33a3b09cdd2cfa01ae70dbf2d18b2d7d168524440e55d550088000000070011c304cd7eb5c0000000000000000000000001000000013cb7d3842e8cee6a0ebd09f1fe884f6861e1b29c83497819" 1382 ], 1383 "endIndex": { 1384 "address": "X-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5", 1385 "utxo": "2Sz2XwRYqUHwPeiKoRnZ6ht88YqzAF1SQjMYZQQaB5wBFkAqST" 1386 }, 1387 "encoding": "hex" 1388 }, 1389 "id": 1 1390 } 1391 ``` 1392 1393 ### `avm.import` 1394 1395 :::caution 1396 1397 Deprecated as of [**v1.9.12**](https://github.com/ava-labs/avalanchego/releases/tag/v1.9.12). 1398 1399 ::: 1400 1401 :::warning 1402 Not recommended for use on Mainnet. See warning notice in [Keystore API](/reference/avalanchego/keystore-api.md). 1403 ::: 1404 1405 Finalize a transfer of an asset from the P-Chain or C-Chain to the X-Chain. 1406 1407 **Signature:** 1408 1409 ```sh 1410 avm.import({ 1411 to: string, 1412 sourceChain: string, 1413 username: string, 1414 password: string, 1415 }) -> {txID: string} 1416 ``` 1417 1418 - `to` is the address the AVAX is sent to. This must be the same as the `to` argument in the 1419 corresponding call to the P-Chain’s `exportAVAX` or C-Chain's `export`. 1420 - `sourceChain` is the ID or alias of the chain the AVAX is being imported from. To import funds 1421 from the C-Chain, use `"C"`. 1422 - `username` is the user that controls `to`. 1423 - `txID` is the ID of the newly created atomic transaction. 1424 1425 **Example Call:** 1426 1427 ```sh 1428 curl -X POST --data '{ 1429 "jsonrpc":"2.0", 1430 "id" :1, 1431 "method" :"avm.import", 1432 "params" :{ 1433 "to":"X-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5", 1434 "sourceChain":"C", 1435 "username":"myUsername", 1436 "password":"myPassword" 1437 } 1438 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/X 1439 ``` 1440 1441 **Example Response:** 1442 1443 ```json 1444 { 1445 "jsonrpc": "2.0", 1446 "result": { 1447 "txID": "2gXpf4jFoMAWQ3rxBfavgFfSdLkL2eFUYprKsUQuEdB5H6Jo1H" 1448 }, 1449 "id": 1 1450 } 1451 ``` 1452 1453 <!-- 1454 TODO: Add avm.importAVAX 1455 --> 1456 1457 ### `avm.importKey` 1458 1459 :::caution 1460 1461 Deprecated as of [**v1.9.12**](https://github.com/ava-labs/avalanchego/releases/tag/v1.9.12). 1462 1463 ::: 1464 1465 :::warning 1466 Not recommended for use on Mainnet. See warning notice in [Keystore API](/reference/avalanchego/keystore-api.md). 1467 ::: 1468 1469 Give a user control over an address by providing the private key that controls the address. 1470 1471 **Signature:** 1472 1473 ```sh 1474 avm.importKey({ 1475 username: string, 1476 password: string, 1477 privateKey: string 1478 }) -> {address: string} 1479 ``` 1480 1481 - Add `privateKey` to `username`‘s set of private keys. `address` is the address `username` now 1482 controls with the private key. 1483 1484 **Example Call:** 1485 1486 ```sh 1487 curl -X POST --data '{ 1488 "jsonrpc":"2.0", 1489 "id" :1, 1490 "method" :"avm.importKey", 1491 "params" :{ 1492 "username":"myUsername", 1493 "password":"myPassword", 1494 "privateKey":"PrivateKey-2w4XiXxPfQK4TypYqnohRL8DRNTz9cGiGmwQ1zmgEqD9c9KWLq" 1495 } 1496 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/X 1497 ``` 1498 1499 **Example Response:** 1500 1501 ```json 1502 { 1503 "jsonrpc": "2.0", 1504 "id": 1, 1505 "result": { 1506 "address": "X-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5" 1507 } 1508 } 1509 ``` 1510 1511 ### `avm.issueTx` 1512 1513 Send a signed transaction to the network. `encoding` specifies the format of the signed transaction. 1514 Can only be `hex` when a value is provided. 1515 1516 **Signature:** 1517 1518 ```sh 1519 avm.issueTx({ 1520 tx: string, 1521 encoding: string, //optional 1522 }) -> { 1523 txID: string 1524 } 1525 ``` 1526 1527 **Example Call:** 1528 1529 ```sh 1530 curl -X POST --data '{ 1531 "jsonrpc":"2.0", 1532 "id" : 1, 1533 "method" :"avm.issueTx", 1534 "params" :{ 1535 "tx":"0x00000009de31b4d8b22991d51aa6aa1fc733f23a851a8c9400000000000186a0000000005f041280000000005f9ca900000030390000000000000001fceda8f90fcb5d30614b99d79fc4baa29307762668f16eb0259a57c2d3b78c875c86ec2045792d4df2d926c40f829196e0bb97ee697af71f5b0a966dabff749634c8b729855e937715b0e44303fd1014daedc752006011b730", 1536 "encoding": "hex" 1537 } 1538 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/X 1539 ``` 1540 1541 **Example Response:** 1542 1543 ```json 1544 { 1545 "jsonrpc": "2.0", 1546 "id": 1, 1547 "result": { 1548 "txID": "NUPLwbt2hsYxpQg4H2o451hmTWQ4JZx2zMzM4SinwtHgAdX1JLPHXvWSXEnpecStLj" 1549 } 1550 } 1551 ``` 1552 1553 ### `avm.listAddresses` 1554 1555 :::caution 1556 1557 Deprecated as of [**v1.9.12**](https://github.com/ava-labs/avalanchego/releases/tag/v1.9.12). 1558 1559 ::: 1560 1561 :::warning 1562 Not recommended for use on Mainnet. See warning notice in [Keystore API](/reference/avalanchego/keystore-api.md). 1563 ::: 1564 1565 List addresses controlled by the given user. 1566 1567 **Signature:** 1568 1569 ```sh 1570 avm.listAddresses({ 1571 username: string, 1572 password: string 1573 }) -> {addresses: []string} 1574 ``` 1575 1576 **Example Call:** 1577 1578 ```sh 1579 curl -X POST --data '{ 1580 "jsonrpc": "2.0", 1581 "method": "avm.listAddresses", 1582 "params": { 1583 "username":"myUsername", 1584 "password":"myPassword" 1585 }, 1586 "id": 1 1587 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/X 1588 ``` 1589 1590 **Example Response:** 1591 1592 ```json 1593 { 1594 "jsonrpc": "2.0", 1595 "result": { 1596 "addresses": ["X-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5"] 1597 }, 1598 "id": 1 1599 } 1600 ``` 1601 1602 ### `avm.mint` 1603 1604 :::caution 1605 1606 Deprecated as of [**v1.9.12**](https://github.com/ava-labs/avalanchego/releases/tag/v1.9.12). 1607 1608 ::: 1609 1610 :::warning 1611 Not recommended for use on Mainnet. See warning notice in [Keystore API](/reference/avalanchego/keystore-api.md). 1612 ::: 1613 1614 Mint units of a variable-cap asset created with 1615 [`avm.createVariableCapAsset`](/reference/avalanchego/x-chain/api.md#avmcreatevariablecapasset). 1616 1617 **Signature:** 1618 1619 ```sh 1620 avm.mint({ 1621 amount: int, 1622 assetID: string, 1623 to: string, 1624 from: []string, //optional 1625 changeAddr: string, //optional 1626 username: string, 1627 password: string 1628 }) -> 1629 { 1630 txID: string, 1631 changeAddr: string, 1632 } 1633 ``` 1634 1635 - `amount` units of `assetID` will be created and controlled by address `to`. 1636 - `from` are the addresses that you want to use for this operation. If omitted, uses any of your 1637 addresses as needed. 1638 - `changeAddr` is the address any change will be sent to. If omitted, change is sent to one of the 1639 addresses controlled by the user. 1640 - `username` is the user that pays the transaction fee. `username` must hold keys giving it 1641 permission to mint more of this asset. That is, it must control at least _threshold_ keys for one 1642 of the minter sets. 1643 - `txID` is this transaction’s ID. 1644 - `changeAddr` in the result is the address where any change was sent. 1645 1646 **Example Call:** 1647 1648 ```sh 1649 curl -X POST --data '{ 1650 "jsonrpc":"2.0", 1651 "id" : 1, 1652 "method" :"avm.mint", 1653 "params" :{ 1654 "amount":10000000, 1655 "assetID":"i1EqsthjiFTxunrj8WD2xFSrQ5p2siEKQacmCCB5qBFVqfSL2", 1656 "to":"X-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5", 1657 "from":["X-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5"], 1658 "changeAddr":"X-avax1turszjwn05lflpewurw96rfrd3h6x8flgs5uf8", 1659 "username":"myUsername", 1660 "password":"myPassword" 1661 } 1662 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/X 1663 ``` 1664 1665 **Example Response:** 1666 1667 ```json 1668 { 1669 "jsonrpc": "2.0", 1670 "id": 1, 1671 "result": { 1672 "txID": "2oGdPdfw2qcNUHeqjw8sU2hPVrFyNUTgn6A8HenDra7oLCDtja", 1673 "changeAddr": "X-avax1turszjwn05lflpewurw96rfrd3h6x8flgs5uf8" 1674 } 1675 } 1676 ``` 1677 1678 ### `avm.mintNFT` 1679 1680 :::caution 1681 1682 Deprecated as of [**v1.9.12**](https://github.com/ava-labs/avalanchego/releases/tag/v1.9.12). 1683 1684 ::: 1685 1686 :::warning 1687 Not recommended for use on Mainnet. See warning notice in [Keystore API](/reference/avalanchego/keystore-api.md). 1688 ::: 1689 1690 Mint non-fungible tokens which were created with 1691 [`avm.createNFTAsset`](/reference/avalanchego/x-chain/api.md#avmcreatenftasset). 1692 1693 **Signature:** 1694 1695 ```sh 1696 avm.mintNFT({ 1697 assetID: string, 1698 payload: string, 1699 to: string, 1700 encoding: string, //optional 1701 from: []string, //optional 1702 changeAddr: string, //optional 1703 username: string, 1704 password: string 1705 }) -> 1706 { 1707 txID: string, 1708 changeAddr: string, 1709 } 1710 ``` 1711 1712 - `assetID` is the assetID of the newly created NFT asset. 1713 - `payload` is an arbitrary payload of up to 1024 bytes. Its encoding format is specified by the 1714 `encoding` argument. 1715 - `from` are the addresses that you want to use for this operation. If omitted, uses any of your 1716 addresses as needed. 1717 - `changeAddr` is the address any change will be sent to. If omitted, change is sent to one of the 1718 addresses controlled by the user. 1719 - `username` is the user that pays the transaction fee. `username` must hold keys giving it 1720 permission to mint more of this asset. That is, it must control at least _threshold_ keys for one 1721 of the minter sets. 1722 - `txID` is this transaction’s ID. 1723 - `changeAddr` in the result is the address where any change was sent. 1724 - `encoding` is the encoding format to use for the payload argument. Can only be `hex` when a value 1725 is provided. 1726 1727 **Example Call:** 1728 1729 ```sh 1730 curl -X POST --data '{ 1731 "jsonrpc":"2.0", 1732 "id" : 1, 1733 "method" :"avm.mintNFT", 1734 "params" :{ 1735 "assetID":"2KGdt2HpFKpTH5CtGZjYt5XPWs6Pv9DLoRBhiFfntbezdRvZWP", 1736 "payload":"0x415641204c61627338259aed", 1737 "to":"X-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5", 1738 "from":["X-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5"], 1739 "changeAddr":"X-avax1turszjwn05lflpewurw96rfrd3h6x8flgs5uf8", 1740 "username":"myUsername", 1741 "password":"myPassword" 1742 } 1743 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/X 1744 ``` 1745 1746 **Example Response:** 1747 1748 ```json 1749 { 1750 "jsonrpc": "2.0", 1751 "id": 1, 1752 "result": { 1753 "txID": "2oGdPdfw2qcNUHeqjw8sU2hPVrFyNUTgn6A8HenDra7oLCDtja", 1754 "changeAddr": "X-avax1turszjwn05lflpewurw96rfrd3h6x8flgs5uf8" 1755 } 1756 } 1757 ``` 1758 1759 ### `avm.send` 1760 1761 :::caution 1762 1763 Deprecated as of [**v1.9.12**](https://github.com/ava-labs/avalanchego/releases/tag/v1.9.12). 1764 1765 ::: 1766 1767 :::warning 1768 Not recommended for use on Mainnet. See warning notice in [Keystore API](/reference/avalanchego/keystore-api.md). 1769 ::: 1770 1771 Send a quantity of an asset to an address. 1772 1773 **Signature:** 1774 1775 ```sh 1776 avm.send({ 1777 amount: int, 1778 assetID: string, 1779 to: string, 1780 memo: string, //optional 1781 from: []string, //optional 1782 changeAddr: string, //optional 1783 username: string, 1784 password: string 1785 }) -> {txID: string, changeAddr: string} 1786 ``` 1787 1788 - Sends `amount` units of asset with ID `assetID` to address `to`. `amount` is denominated in the 1789 smallest increment of the asset. For AVAX this is 1 nAVAX (one billionth of 1 AVAX.) 1790 - `to` is the X-Chain address the asset is sent to. 1791 - `from` are the addresses that you want to use for this operation. If omitted, uses any of your 1792 addresses as needed. 1793 - `changeAddr` is the address any change will be sent to. If omitted, change is sent to one of the 1794 addresses controlled by the user. 1795 - You can attach a `memo`, whose length can be up to 256 bytes. 1796 - The asset is sent from addresses controlled by user `username`. (Of course, that user will need to 1797 hold at least the balance of the asset being sent.) 1798 1799 **Example Call:** 1800 1801 ```sh 1802 curl -X POST --data '{ 1803 "jsonrpc":"2.0", 1804 "id" :1, 1805 "method" :"avm.send", 1806 "params" :{ 1807 "assetID" : "AVAX", 1808 "amount" : 10000, 1809 "to" : "X-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5", 1810 "from" : ["X-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5"], 1811 "changeAddr": "X-avax1turszjwn05lflpewurw96rfrd3h6x8flgs5uf8", 1812 "memo" : "hi, mom!", 1813 "username" : "userThatControlsAtLeast10000OfThisAsset", 1814 "password" : "myPassword" 1815 } 1816 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/X 1817 ``` 1818 1819 **Example Response:** 1820 1821 ```json 1822 { 1823 "jsonrpc": "2.0", 1824 "id": 1, 1825 "result": { 1826 "txID": "2iXSVLPNVdnFqn65rRvLrsu8WneTFqBJRMqkBJx5vZTwAQb8c1", 1827 "changeAddr": "X-avax1turszjwn05lflpewurw96rfrd3h6x8flgs5uf8" 1828 } 1829 } 1830 ``` 1831 1832 ### `avm.sendMultiple` 1833 1834 :::caution 1835 1836 Deprecated as of [**v1.9.12**](https://github.com/ava-labs/avalanchego/releases/tag/v1.9.12). 1837 1838 ::: 1839 1840 :::warning 1841 Not recommended for use on Mainnet. See warning notice in [Keystore API](/reference/avalanchego/keystore-api.md). 1842 ::: 1843 1844 Sends multiple transfers of `amount` of `assetID`, to a specified address from a list of owned 1845 addresses. 1846 1847 **Signature:** 1848 1849 ```sh 1850 avm.sendMultiple({ 1851 outputs: []{ 1852 assetID: string, 1853 amount: int, 1854 to: string 1855 }, 1856 from: []string, //optional 1857 changeAddr: string, //optional 1858 memo: string, //optional 1859 username: string, 1860 password: string 1861 }) -> {txID: string, changeAddr: string} 1862 ``` 1863 1864 - `outputs` is an array of object literals which each contain an `assetID`, `amount` and `to`. 1865 - `memo` is an optional message, whose length can be up to 256 bytes. 1866 - `from` are the addresses that you want to use for this operation. If omitted, uses any of your 1867 addresses as needed. 1868 - `changeAddr` is the address any change will be sent to. If omitted, change is sent to one of the 1869 addresses controlled by the user. 1870 - The asset is sent from addresses controlled by user `username`. (Of course, that user will need to 1871 hold at least the balance of the asset being sent.) 1872 1873 **Example Call:** 1874 1875 ```sh 1876 curl -X POST --data '{ 1877 "jsonrpc":"2.0", 1878 "id" :1, 1879 "method" :"avm.sendMultiple", 1880 "params" :{ 1881 "outputs": [ 1882 { 1883 "assetID" : "AVAX", 1884 "to" : "X-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5", 1885 "amount" : 1000000000 1886 }, 1887 { 1888 "assetID" : "26aqSTpZuWDAVtRmo44fjCx4zW6PDEx3zy9Qtp2ts1MuMFn9FB", 1889 "to" : "X-avax18knvhxx8uhc0mwlgrfyzjcm2wrd6e60w37xrjq", 1890 "amount" : 10 1891 } 1892 ], 1893 "memo" : "hi, mom!", 1894 "from" : ["X-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5"], 1895 "changeAddr": "X-avax1turszjwn05lflpewurw96rfrd3h6x8flgs5uf8", 1896 "username" : "username", 1897 "password" : "myPassword" 1898 } 1899 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/X 1900 ``` 1901 1902 **Example Response:** 1903 1904 ```json 1905 { 1906 "jsonrpc": "2.0", 1907 "id": 1, 1908 "result": { 1909 "txID": "2iXSVLPNVdnFqn65rRvLrsu8WneTFqBJRMqkBJx5vZTwAQb8c1", 1910 "changeAddr": "X-avax1turszjwn05lflpewurw96rfrd3h6x8flgs5uf8" 1911 } 1912 } 1913 ``` 1914 1915 ### `avm.sendNFT` 1916 1917 :::caution 1918 1919 Deprecated as of [**v1.9.12**](https://github.com/ava-labs/avalanchego/releases/tag/v1.9.12). 1920 1921 ::: 1922 1923 :::warning 1924 Not recommended for use on Mainnet. See warning notice in [Keystore API](/reference/avalanchego/keystore-api.md). 1925 ::: 1926 1927 Send a non-fungible token. 1928 1929 **Signature:** 1930 1931 ```sh 1932 avm.sendNFT({ 1933 assetID: string, 1934 groupID: number, 1935 to: string, 1936 from: []string, //optional 1937 changeAddr: string, //optional 1938 username: string, 1939 password: string 1940 }) -> {txID: string} 1941 ``` 1942 1943 - `assetID` is the asset ID of the NFT being sent. 1944 - `groupID` is the NFT group from which to send the NFT. NFT creation allows multiple groups under 1945 each NFT ID. You can issue multiple NFTs to each group. 1946 - `to` is the X-Chain address the NFT is sent to. 1947 - `from` are the addresses that you want to use for this operation. If omitted, uses any of your 1948 addresses as needed. `changeAddr` is the address any change will be sent to. If omitted, change is 1949 sent to one of the addresses controlled by the user. 1950 - The asset is sent from addresses controlled by user `username`. (Of course, that user will need to 1951 hold at least the balance of the NFT being sent.) 1952 1953 **Example Call:** 1954 1955 ```sh 1956 curl -X POST --data '{ 1957 "jsonrpc":"2.0", 1958 "id" :1, 1959 "method" :"avm.sendNFT", 1960 "params" :{ 1961 "assetID" : "2KGdt2HpFKpTH5CtGZjYt5XPWs6Pv9DLoRBhiFfntbezdRvZWP", 1962 "groupID" : 0, 1963 "to" : "X-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5", 1964 "from" : ["X-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5"], 1965 "changeAddr": "X-avax1turszjwn05lflpewurw96rfrd3h6x8flgs5uf8", 1966 "username" : "myUsername", 1967 "password" : "myPassword" 1968 } 1969 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/X 1970 ``` 1971 1972 **Example Response:** 1973 1974 ```json 1975 { 1976 "jsonrpc": "2.0", 1977 "result": { 1978 "txID": "DoR2UtG1Trd3Q8gWXVevNxD666Q3DPqSFmBSMPQ9dWTV8Qtuy", 1979 "changeAddr": "X-avax1turszjwn05lflpewurw96rfrd3h6x8flgs5uf8" 1980 }, 1981 "id": 1 1982 } 1983 ``` 1984 1985 ### `wallet.issueTx` 1986 1987 Send a signed transaction to the network and assume the TX will be accepted. `encoding` specifies 1988 the format of the signed transaction. Can only be `hex` when a value is provided. 1989 1990 This call is made to the wallet API endpoint: 1991 1992 `/ext/bc/X/wallet` 1993 1994 :::caution 1995 1996 Endpoint deprecated as of [**v1.9.12**](https://github.com/ava-labs/avalanchego/releases/tag/v1.9.12). 1997 1998 ::: 1999 2000 **Signature:** 2001 2002 ```sh 2003 wallet.issueTx({ 2004 tx: string, 2005 encoding: string, //optional 2006 }) -> { 2007 txID: string 2008 } 2009 ``` 2010 2011 **Example Call:** 2012 2013 ```sh 2014 curl -X POST --data '{ 2015 "jsonrpc":"2.0", 2016 "id" : 1, 2017 "method" :"wallet.issueTx", 2018 "params" :{ 2019 "tx":"0x00000009de31b4d8b22991d51aa6aa1fc733f23a851a8c9400000000000186a0000000005f041280000000005f9ca900000030390000000000000001fceda8f90fcb5d30614b99d79fc4baa29307762668f16eb0259a57c2d3b78c875c86ec2045792d4df2d926c40f829196e0bb97ee697af71f5b0a966dabff749634c8b729855e937715b0e44303fd1014daedc752006011b730", 2020 "encoding": "hex" 2021 } 2022 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/X/wallet 2023 ``` 2024 2025 **Example Response:** 2026 2027 ```json 2028 { 2029 "jsonrpc": "2.0", 2030 "id": 1, 2031 "result": { 2032 "txID": "NUPLwbt2hsYxpQg4H2o451hmTWQ4JZx2zMzM4SinwtHgAdX1JLPHXvWSXEnpecStLj" 2033 } 2034 } 2035 ``` 2036 2037 ### `wallet.send` 2038 2039 :::warning 2040 Not recommended for use on Mainnet. See warning notice in [Keystore API](/reference/avalanchego/keystore-api.md). 2041 ::: 2042 2043 Send a quantity of an asset to an address and assume the TX will be accepted so that future calls 2044 can use the modified UTXO set. 2045 2046 This call is made to the wallet API endpoint: 2047 2048 `/ext/bc/X/wallet` 2049 2050 :::caution 2051 2052 Endpoint deprecated as of [**v1.9.12**](https://github.com/ava-labs/avalanchego/releases/tag/v1.9.12). 2053 2054 ::: 2055 2056 **Signature:** 2057 2058 ```sh 2059 wallet.send({ 2060 amount: int, 2061 assetID: string, 2062 to: string, 2063 memo: string, //optional 2064 from: []string, //optional 2065 changeAddr: string, //optional 2066 username: string, 2067 password: string 2068 }) -> {txID: string, changeAddr: string} 2069 ``` 2070 2071 - Sends `amount` units of asset with ID `assetID` to address `to`. `amount` is denominated in the 2072 smallest increment of the asset. For AVAX this is 1 nAVAX (one billionth of 1 AVAX.) 2073 - `to` is the X-Chain address the asset is sent to. 2074 - `from` are the addresses that you want to use for this operation. If omitted, uses any of your 2075 addresses as needed. 2076 - `changeAddr` is the address any change will be sent to. If omitted, change is sent to one of the 2077 addresses controlled by the user. 2078 - You can attach a `memo`, whose length can be up to 256 bytes. 2079 - The asset is sent from addresses controlled by user `username`. (Of course, that user will need to 2080 hold at least the balance of the asset being sent.) 2081 2082 **Example Call:** 2083 2084 ```sh 2085 curl -X POST --data '{ 2086 "jsonrpc":"2.0", 2087 "id" :1, 2088 "method" :"wallet.send", 2089 "params" :{ 2090 "assetID" : "AVAX", 2091 "amount" : 10000, 2092 "to" : "X-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5", 2093 "memo" : "hi, mom!", 2094 "from" : ["X-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5"], 2095 "changeAddr": "X-avax1turszjwn05lflpewurw96rfrd3h6x8flgs5uf8", 2096 "username" : "userThatControlsAtLeast10000OfThisAsset", 2097 "password" : "myPassword" 2098 } 2099 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/X/wallet 2100 ``` 2101 2102 **Example Response:** 2103 2104 ```json 2105 { 2106 "jsonrpc": "2.0", 2107 "id": 1, 2108 "result": { 2109 "txID": "2iXSVLPNVdnFqn65rRvLrsu8WneTFqBJRMqkBJx5vZTwAQb8c1", 2110 "changeAddr": "X-avax1turszjwn05lflpewurw96rfrd3h6x8flgs5uf8" 2111 } 2112 } 2113 ``` 2114 2115 ### `wallet.sendMultiple` 2116 2117 :::warning 2118 Not recommended for use on Mainnet. See warning notice in [Keystore API](/reference/avalanchego/keystore-api.md). 2119 ::: 2120 2121 Send multiple transfers of `amount` of `assetID`, to a specified address from a list of owned of 2122 addresses and assume the TX will be accepted so that future calls can use the modified UTXO set. 2123 2124 This call is made to the wallet API endpoint: 2125 2126 `/ext/bc/X/wallet` 2127 2128 :::caution 2129 2130 Endpoint deprecated as of [**v1.9.12**](https://github.com/ava-labs/avalanchego/releases/tag/v1.9.12). 2131 2132 ::: 2133 2134 **Signature:** 2135 2136 ```sh 2137 wallet.sendMultiple({ 2138 outputs: []{ 2139 assetID: string, 2140 amount: int, 2141 to: string 2142 }, 2143 from: []string, //optional 2144 changeAddr: string, //optional 2145 memo: string, //optional 2146 username: string, 2147 password: string 2148 }) -> {txID: string, changeAddr: string} 2149 ``` 2150 2151 - `outputs` is an array of object literals which each contain an `assetID`, `amount` and `to`. 2152 - `from` are the addresses that you want to use for this operation. If omitted, uses any of your 2153 addresses as needed. 2154 - `changeAddr` is the address any change will be sent to. If omitted, change is sent to one of the 2155 addresses controlled by the user. 2156 - You can attach a `memo`, whose length can be up to 256 bytes. 2157 - The asset is sent from addresses controlled by user `username`. (Of course, that user will need to 2158 hold at least the balance of the asset being sent.) 2159 2160 **Example Call:** 2161 2162 ```sh 2163 curl -X POST --data '{ 2164 "jsonrpc":"2.0", 2165 "id" :1, 2166 "method" :"wallet.sendMultiple", 2167 "params" :{ 2168 "outputs": [ 2169 { 2170 "assetID" : "AVAX", 2171 "to" : "X-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5", 2172 "amount" : 1000000000 2173 }, 2174 { 2175 "assetID" : "26aqSTpZuWDAVtRmo44fjCx4zW6PDEx3zy9Qtp2ts1MuMFn9FB", 2176 "to" : "X-avax18knvhxx8uhc0mwlgrfyzjcm2wrd6e60w37xrjq", 2177 "amount" : 10 2178 } 2179 ], 2180 "memo" : "hi, mom!", 2181 "from" : ["X-avax18jma8ppw3nhx5r4ap8clazz0dps7rv5ukulre5"], 2182 "changeAddr": "X-avax1turszjwn05lflpewurw96rfrd3h6x8flgs5uf8", 2183 "username" : "username", 2184 "password" : "myPassword" 2185 } 2186 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/X/wallet 2187 ``` 2188 2189 **Example Response:** 2190 2191 ```json 2192 { 2193 "jsonrpc": "2.0", 2194 "id": 1, 2195 "result": { 2196 "txID": "2iXSVLPNVdnFqn65rRvLrsu8WneTFqBJRMqkBJx5vZTwAQb8c1", 2197 "changeAddr": "X-avax1turszjwn05lflpewurw96rfrd3h6x8flgs5uf8" 2198 } 2199 } 2200 ``` 2201 2202 ### Events 2203 2204 Listen for transactions on a specified address. 2205 2206 This call is made to the events API endpoint: 2207 2208 `/ext/bc/X/events` 2209 2210 :::caution 2211 2212 Endpoint deprecated as of [**v1.9.12**](https://github.com/ava-labs/avalanchego/releases/tag/v1.9.12). 2213 2214 ::: 2215 2216 #### **Golang Example** 2217 2218 ```go 2219 package main 2220 2221 import ( 2222 "encoding/json" 2223 "log" 2224 "net" 2225 "net/http" 2226 "sync" 2227 2228 "github.com/ava-labs/avalanchego/api" 2229 "github.com/ava-labs/avalanchego/pubsub" 2230 "github.com/gorilla/websocket" 2231 ) 2232 2233 func main() { 2234 dialer := websocket.Dialer{ 2235 NetDial: func(netw, addr string) (net.Conn, error) { 2236 return net.Dial(netw, addr) 2237 }, 2238 } 2239 2240 httpHeader := http.Header{} 2241 conn, _, err := dialer.Dial("ws://localhost:9650/ext/bc/X/events", httpHeader) 2242 if err != nil { 2243 panic(err) 2244 } 2245 2246 waitGroup := &sync.WaitGroup{} 2247 waitGroup.Add(1) 2248 2249 readMsg := func() { 2250 defer waitGroup.Done() 2251 2252 for { 2253 mt, msg, err := conn.ReadMessage() 2254 if err != nil { 2255 log.Println(err) 2256 return 2257 } 2258 switch mt { 2259 case websocket.TextMessage: 2260 log.Println(string(msg)) 2261 default: 2262 log.Println(mt, string(msg)) 2263 } 2264 } 2265 } 2266 2267 go readMsg() 2268 2269 cmd := &pubsub.Command{NewSet: &pubsub.NewSet{}} 2270 cmdmsg, err := json.Marshal(cmd) 2271 if err != nil { 2272 panic(err) 2273 } 2274 err = conn.WriteMessage(websocket.TextMessage, cmdmsg) 2275 if err != nil { 2276 panic(err) 2277 } 2278 2279 var addresses []string 2280 addresses = append(addresses, " X-fuji....") 2281 cmd = &pubsub.Command{AddAddresses: &pubsub.AddAddresses{JSONAddresses: api.JSONAddresses{Addresses: addresses}}} 2282 cmdmsg, err = json.Marshal(cmd) 2283 if err != nil { 2284 panic(err) 2285 } 2286 2287 err = conn.WriteMessage(websocket.TextMessage, cmdmsg) 2288 if err != nil { 2289 panic(err) 2290 } 2291 2292 waitGroup.Wait() 2293 } 2294 ``` 2295 2296 **Operations:** 2297 2298 | Command | Description | Example | Arguments | 2299 | :--------------- | :--------------------------- | :------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------- | 2300 | **NewSet** | create a new address map set | `{"newSet":{}}` | | 2301 | **NewBloom** | create a new bloom set. | `{"newBloom":{"maxElements":"1000","collisionProb":"0.0100"}}` | `maxElements` - number of elements in filter must be > 0 `collisionProb` - allowed collision probability must be > 0 and <= 1 | 2302 | **AddAddresses** | add an address to the set | `{"addAddresses":{"addresses":\["X-fuji..."\]}}` | addresses - list of addresses to match | 2303 2304 Calling **NewSet** or **NewBloom** resets the filter, and must be followed with **AddAddresses**. 2305 **AddAddresses** can be called multiple times. 2306 2307 **Set details:** 2308 2309 - **NewSet** performs absolute address matches, if the address is in the set you will be sent the 2310 transaction. 2311 - **NewBloom** [Bloom filtering](https://en.wikipedia.org/wiki/Bloom_filter) can produce false 2312 positives, but can allow a greater number of addresses to be filtered. If the addresses is in the 2313 filter, you will be sent the transaction. 2314 2315 **Example Response:** 2316 2317 ```json 2318 2021/05/11 15:59:35 {"txID":"22HWKHrREyXyAiDnVmGp3TQQ79tHSSVxA9h26VfDEzoxvwveyk"} 2319 ```