Infrastructure as CodeSVM Addon

SVM Actions

Actions for Solana and SVM Compatible Blockchains

These actions are available when using the SVM addon for transaction building, signing, and broadcasting.

deploy_program

svm::deploy_program deploys a Solana program to the specified SVM-compatible network.

Inputs

NameRequiredTypeDescription
descriptionoptionalstringA description of the deployment action
programrequiredobjectThe Solana program artifacts to deploy
payeroptionalstringA reference to a signer for paying deployment costs
authorityrequiredstringA reference to a signer for the program authority
commitment_leveloptionalstringThe commitment level ('processed', 'confirmed', 'finalized')
auto_extendoptionalboolWhether to auto extend the program account (default: true)

Outputs

NameTypeDescription
signaturesobjectThe computed transaction signatures
program_idstringThe program ID of the deployed program
program_idlstringThe program IDL
action "deploy" "svm::deploy_program" {
    description = "Deploy hello world program"
    program = svm::get_program_from_anchor_project("hello_world")
    authority = signer.authority
    payer = signer.payer  # Optional, defaults to authority
}

process_instructions

The svm::process_instructions action encodes instructions, adds them to a transaction, and signs & broadcasts the transaction.

Inputs

NameRequiredTypeDescription
descriptionoptionalstringA description of the transaction
instructionrequiredmapThe instructions to add to the transaction
signersrequiredarray[string]References to signer constructs
commitment_leveloptionalstringThe commitment level
rpc_api_urlrequiredstringThe URL for API requests

Outputs

NameTypeDescription
signaturestringThe transaction computed signature
action "program_call" "svm::process_instructions" {
    description = "Invoke instructions"
    instruction {
        program_idl = variable.program.idl
        instruction_name = "initialize"
        instruction_args = [1]
        payer {
            public_key = signer.payer.public_key
        }
    }
    signers = [signer.caller]
}

send_sol

The svm::send_sol action encodes a transaction which sends SOL, signs it, and broadcasts it to the network.

Inputs

NameRequiredTypeDescription
descriptionoptionalstringA description of the transaction
amountrequiredintegerThe amount to send, in lamports
recipientrequiredstringThe SVM address of the recipient
signerrequiredstringA reference to a signer construct
commitment_leveloptionalstringThe commitment level
rpc_api_urlrequiredstringThe URL for API requests

Outputs

NameTypeDescription
signaturestringThe transaction computed signature
action "send_sol" "svm::send_sol" {
    description = "Send some SOL"
    amount = svm::sol_to_lamports(1)
    signer = signer.caller
    recipient = "zbBjhHwuqyKMmz8ber5oUtJJ3ZV4B6ePmANfGyKzVGV"
}

send_token

The svm::send_token action encodes a transaction which sends the specified token, signs it, and broadcasts it to the network.

Inputs

NameRequiredTypeDescription
descriptionoptionalstringA description of the transaction
amountrequiredintegerThe amount of tokens to send, in base unit
tokenrequiredstringThe token mint account address
recipientrequiredstringThe SVM address of the recipient
authorityoptionalstringThe pubkey of the authority account
fund_recipientoptionalboolCreate and fund recipient token account if needed
signersrequiredarray[string]References to signer constructs

Outputs

NameTypeDescription
signaturestringThe transaction computed signature
recipient_token_addresspubkeyThe recipient token account address
source_token_addresspubkeyThe source token account address
token_mint_addresspubkeyThe token mint address
action "send_sol" "svm::send_token" {
    description = "Send some tokens"
    amount = 1000000
    signers = [signer.caller]
    recipient = "zbBjhHwuqyKMmz8ber5oUtJJ3ZV4B6ePmANfGyKzVGV"
    token = "3bv3j4GvMPjvvBX9QdoX27pVoWhDSXpwKZipFF1QiVr6"
    fund_recipient = true
}

setup_surfnet

svm::setup_surfnet can be used to configure a surfnet.

The following operations are supported:

  • set_account - Set the lamports, owner, data, and executable fields of an account
  • set_token_account - Set the amount, delegate, delegated amount, and close authority for a token account
  • clone_program_account - Clone a program account from a source program ID to a destination program ID
  • set_program_authority - Set the authority of a program
  • deploy_program - Deploy a program directly to the surfnet (via direct account write, not transactions)
  • reset_account - Reset an account, removing it from local cache to be re-fetched from upstream
  • stream_account - Stream account data from mainnet so local data always matches mainnet

Inputs

NameRequiredTypeDescription
descriptionoptionalstringA description of the setup
rpc_api_urlrequiredstringThe URL for API requests

set_account

Sets account data directly on the surfnet.

NameRequiredTypeDescription
public_keyrequiredstringThe public key of the account to set
account_pathoptionalstringThe path to a JSON file containing the account data to set. If provided, other fields are ignored
lamportsoptionalintegerThe amount of lamports the account should be set to have
dataoptionalbytesThe data to set in the account
owneroptionalstringThe owner to set for the account
executableoptionalboolThe executability state to set for the account
rent_epochoptionalintegerThe epoch at which the account will be rent-exempt

At least one of lamports, data, owner, executable, or rent_epoch must be provided (unless using account_path).

set_token_account

Sets token account data on the surfnet. The associated token account is automatically derived from the owner's public key and token mint.

NameRequiredTypeDescription
public_keyrequiredstringThe public key of the token owner account to update
tokenrequiredstringThe token symbol (e.g., "usdc", "bonk") or public key for the token mint
token_programoptionalstringThe token program ID. Valid values are token2020, token2022, or a public key (default: token2020)
amountoptionalintegerThe amount of tokens to set
delegateoptionalstringThe public key of the delegate to set, or null to clear
stateoptionalstringThe state of the token account. Valid values are initialized, frozen, or uninitialized
delegated_amountoptionalintegerThe amount of tokens to delegate
close_authorityoptionalstringThe public key of the close authority to set, or null to clear

At least one of amount, delegate, state, delegated_amount, or close_authority must be provided.

clone_program_account

Clones a program account from one program ID to another on the surfnet.

NameRequiredTypeDescription
source_program_idrequiredstringThe public key of the program to clone
destination_program_idrequiredstringThe destination public key of the program

set_program_authority

Sets or removes the upgrade authority of a program on the surfnet.

NameRequiredTypeDescription
program_idrequiredstringThe public key of the program to set the authority for
authorityoptionalstringThe new authority for the program. If not provided, program's authority will be set to None (making it immutable)

deploy_program

Deploys a program directly to the surfnet via account data write (not via transactions).

NameRequiredTypeDescription
program_idrequiredstringThe public key of the program being deployed
binary_pathrequiredstringThe location of the program's .so file (e.g., ./target/deploy/my_program.so)
authorityoptionalstringThe public key of the authority over the program after it is deployed. If not provided, the program will have no authority
idl_pathoptionalstringThe location of the program's IDL file (e.g., ./target/idl/my_program.json)

reset_account

Resets an account on the surfnet, removing it from the local cache so it will be re-fetched from the upstream network.

NameRequiredTypeDescription
public_keyrequiredstringThe public key of the account to reset
include_owned_accountsoptionalboolWhether to recursively delete all accounts owned by this account. Default is false

stream_account

Streams account data from the mainnet RPC URL to the surfnet, keeping the local account data in sync with mainnet.

NameRequiredTypeDescription
public_keyrequiredstringThe public key of the account to stream
include_owned_accountsoptionalboolWhether to recursively stream all accounts owned by this account. Default is false
action "setup" "svm::setup_surfnet" {
    // Set account balance
    set_account {
        public_key = signer.caller.public_key
        lamports = 999999999
    }

    // Set token balance
    set_token_account {
        public_key = signer.caller.public_key
        token = "usdc"
        amount = 1000000
    }

    // Clone a program
    clone_program_account {
        source_program_id = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
        destination_program_id = variable.my_program_id
    }

    // Set program authority
    set_program_authority {
        program_id = variable.my_program_id
        authority = signer.caller.public_key
    }

    // Deploy a program directly
    deploy_program {
        program_id = variable.my_program_id
        binary_path = "./target/deploy/my_program.so"
        idl_path = "./target/idl/my_program.json"
    }

    // Reset an account to re-fetch from upstream
    reset_account {
        public_key = variable.some_pubkey
    }

    // Stream account data from mainnet
    stream_account {
        public_key = variable.some_pubkey
        include_owned_accounts = true
    }
}

deploy_subgraph

svm::deploy_subgraph creates a live GraphQL database for your program.

Inputs

NameRequiredTypeDescription
descriptionoptionalstringA description of the subgraph
subgraph_nameoptionalstringThe name of the subgraph
program_idrequiredstringThe ID of the program to index
program_idlrequiredstringThe IDL of the program
block_heightrequiredintegerThe block height to start indexing from
eventrequiredmapEvents to index in the subgraph
action "transfer_event_subgraph" "svm::deploy_subgraph" {
    program_id = action.deploy.program_id
    program_idl = action.deploy.program_idl
    block_height = action.deploy.block_height
    event {
        name = "TransferEvent"
    }
}

On this page