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
| Name | Required | Type | Description |
|---|---|---|---|
description | optional | string | A description of the deployment action |
program | required | object | The Solana program artifacts to deploy |
payer | optional | string | A reference to a signer for paying deployment costs |
authority | required | string | A reference to a signer for the program authority |
commitment_level | optional | string | The commitment level ('processed', 'confirmed', 'finalized') |
auto_extend | optional | bool | Whether to auto extend the program account (default: true) |
Outputs
| Name | Type | Description |
|---|---|---|
signatures | object | The computed transaction signatures |
program_id | string | The program ID of the deployed program |
program_idl | string | The 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
| Name | Required | Type | Description |
|---|---|---|---|
description | optional | string | A description of the transaction |
instruction | required | map | The instructions to add to the transaction |
signers | required | array[string] | References to signer constructs |
commitment_level | optional | string | The commitment level |
rpc_api_url | required | string | The URL for API requests |
Outputs
| Name | Type | Description |
|---|---|---|
signature | string | The 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
| Name | Required | Type | Description |
|---|---|---|---|
description | optional | string | A description of the transaction |
amount | required | integer | The amount to send, in lamports |
recipient | required | string | The SVM address of the recipient |
signer | required | string | A reference to a signer construct |
commitment_level | optional | string | The commitment level |
rpc_api_url | required | string | The URL for API requests |
Outputs
| Name | Type | Description |
|---|---|---|
signature | string | The 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
| Name | Required | Type | Description |
|---|---|---|---|
description | optional | string | A description of the transaction |
amount | required | integer | The amount of tokens to send, in base unit |
token | required | string | The token mint account address |
recipient | required | string | The SVM address of the recipient |
authority | optional | string | The pubkey of the authority account |
fund_recipient | optional | bool | Create and fund recipient token account if needed |
signers | required | array[string] | References to signer constructs |
Outputs
| Name | Type | Description |
|---|---|---|
signature | string | The transaction computed signature |
recipient_token_address | pubkey | The recipient token account address |
source_token_address | pubkey | The source token account address |
token_mint_address | pubkey | The 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 accountset_token_account- Set the amount, delegate, delegated amount, and close authority for a token accountclone_program_account- Clone a program account from a source program ID to a destination program IDset_program_authority- Set the authority of a programdeploy_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 upstreamstream_account- Stream account data from mainnet so local data always matches mainnet
Inputs
| Name | Required | Type | Description |
|---|---|---|---|
description | optional | string | A description of the setup |
rpc_api_url | required | string | The URL for API requests |
set_account
Sets account data directly on the surfnet.
| Name | Required | Type | Description |
|---|---|---|---|
public_key | required | string | The public key of the account to set |
account_path | optional | string | The path to a JSON file containing the account data to set. If provided, other fields are ignored |
lamports | optional | integer | The amount of lamports the account should be set to have |
data | optional | bytes | The data to set in the account |
owner | optional | string | The owner to set for the account |
executable | optional | bool | The executability state to set for the account |
rent_epoch | optional | integer | The 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.
| Name | Required | Type | Description |
|---|---|---|---|
public_key | required | string | The public key of the token owner account to update |
token | required | string | The token symbol (e.g., "usdc", "bonk") or public key for the token mint |
token_program | optional | string | The token program ID. Valid values are token2020, token2022, or a public key (default: token2020) |
amount | optional | integer | The amount of tokens to set |
delegate | optional | string | The public key of the delegate to set, or null to clear |
state | optional | string | The state of the token account. Valid values are initialized, frozen, or uninitialized |
delegated_amount | optional | integer | The amount of tokens to delegate |
close_authority | optional | string | The 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.
| Name | Required | Type | Description |
|---|---|---|---|
source_program_id | required | string | The public key of the program to clone |
destination_program_id | required | string | The destination public key of the program |
set_program_authority
Sets or removes the upgrade authority of a program on the surfnet.
| Name | Required | Type | Description |
|---|---|---|---|
program_id | required | string | The public key of the program to set the authority for |
authority | optional | string | The 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).
| Name | Required | Type | Description |
|---|---|---|---|
program_id | required | string | The public key of the program being deployed |
binary_path | required | string | The location of the program's .so file (e.g., ./target/deploy/my_program.so) |
authority | optional | string | The public key of the authority over the program after it is deployed. If not provided, the program will have no authority |
idl_path | optional | string | The 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.
| Name | Required | Type | Description |
|---|---|---|---|
public_key | required | string | The public key of the account to reset |
include_owned_accounts | optional | bool | Whether 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.
| Name | Required | Type | Description |
|---|---|---|---|
public_key | required | string | The public key of the account to stream |
include_owned_accounts | optional | bool | Whether 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
| Name | Required | Type | Description |
|---|---|---|---|
description | optional | string | A description of the subgraph |
subgraph_name | optional | string | The name of the subgraph |
program_id | required | string | The ID of the program to index |
program_idl | required | string | The IDL of the program |
block_height | required | integer | The block height to start indexing from |
event | required | map | Events 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"
}
}