Accounts

Unlike most blockchain platforms, accounts on Radix (once Radix Engine v2 and Scrypto move onto the public network) are not simply keypairs. In Scrypto, an account is a component that manages the resources owned by an external actor. It allows and/or disallows resources to be deposited into and withdrawn from it.

An account keeps track of all owned resources in a single place (in its vaults), which makes it easier for end-users to view and manage their assets. Also, because an account exposes the same interface as other components, it can also be programmatically accessed.

The account component described on this page is an early form to get developers started in this new model. Additional features are anticipated to be added to the account component before Scrypto moves onto the Radix network at the Babylon release.

Creating an Account

Account components are instantiated from a special blueprint. However the Scrypto CLI tools also provide short cuts to make it easy to create accounts for use in development and testing.

  1. You can programmatically create an account by calling the new or with_bucket function on the Account blueprint.

    • new function instantiate an Account component with no initial resource;

    • with_bucket is similar to new except that it accepts a Bucket of initial resource.

  2. You can also create an account using the resim command-line tool:

    • resim new-account

Withdrawing Resources From an Account

To withdraw resources from an account, one needs to sign the transaction with the corresponding private keys, as part of the End instruction.

The resim CLI automatically withdraws resources if needed from the default account, and signs the transactions with the default private key.

To change the default account, run:

resim set-default-account <ADDRESS> <PUBLIC_KEY>

Currently each account is associated with one key-pair, but one anticipated extension of the account component before Babylon is support for multi-signature usage.

Transferring Resources to Another Account

The resim CLI provides a convenience method to transfer resources to another account:

USAGE:
    resim transfer [FLAGS] [OPTIONS] <RESOURCE> <RECIPIENT_ADDRESS>

FLAGS:
        --trace      Turn on tracing.
    -h, --help       Prints help information
    -V, --version    Prints version information

OPTIONS:
        --signers <SIGNERS>    Specify the transaction signers, separated by comma.

ARGS:
    <RESOURCE>             Specify the resource to transfer, e.g. "amount,resource_address" or
                           "#nft_id1,#nft_id2,..,resource_address".
    <RECIPIENT_ADDRESS>    Specify the recipient address.

Account ABI

In the current Scrypto release for local development, the account blueprint is published at a fixed location:

  • package address: 010000000000000000000000000000000000000000000000000003;

  • blueprint name: Account.

To see the latest Account ABI:

resim export-abi 010000000000000000000000000000000000000000000000000003 Account