Skip to main content
This method returns a SolanaInstruction. Add it to a transaction and use the Transaction Service to execute it on-chain. See Instructions & Transactions.

Allocate

Allocates a specific number of bytes of data space to an existing account. The account must be a signer. Use this before assigning the account to a program that requires specific data storage.

Request

account
Base58-encoded public key (string)
required
The account to allocate space for. Must be a signer.
space
uint64
required
Number of bytes to allocate. Programs typically have fixed data layout sizes.

Response

instruction
SolanaInstruction (object)
The allocate instruction. Add this to a transaction and submit it via the Transaction Service.

Code Examples

resp, err := client.Allocate(ctx, &system_v1.AllocateRequest{
    Account: "7EcDhSYGxXyscszYEp35KHN8vvw3svAuLKTzXwCFLtV",
    Space:   165,
})
if err != nil {
    log.Fatal(err)
}
// Add instruction to your transaction
instruction := resp.Instruction

AllocateWithSeed

Allocates space for a seed-derived account. The base key must sign the transaction — not the derived account address.

Request

account
Base58-encoded public key (string)
required
The seed-derived account address to allocate space for.
base
Base58-encoded public key (string)
required
Base public key used to derive account. Must be a signer.
seed
string
required
Seed string used to derive account.
space
uint64
required
Number of bytes to allocate.

Response

instruction
SolanaInstruction (object)
The allocate_with_seed instruction. Add this to a transaction and submit it via the Transaction Service.

Code Examples

resp, err := client.AllocateWithSeed(ctx, &system_v1.AllocateWithSeedRequest{
    Account: "9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin",
    Base:    "7EcDhSYGxXyscszYEp35KHN8vvw3svAuLKTzXwCFLtV",
    Seed:    "my-program-data",
    Space:   165,
})
if err != nil {
    log.Fatal(err)
}
// Add instruction to your transaction
instruction := resp.Instruction