Solana and SVM Compatible Blockchains (beta) Actions

action

sign_transaction

The svm::send_transaction is used to sign a transaction and broadcast it to the specified SVM-compatible network.

Inputs

  • Name
    description
    Required
    optional
    Type
    string
    Description

    A description of the transaction.

  • Name
    transaction_bytes
    Required
    required
    Type
    addon(svm::transaction)
    Description

    The transaction bytes to sign.

  • Name
    signers
    Required
    optional
    Type
    array[string]
    Description

    A set of references to signer constructs, which will be used to sign the transaction.

  • Name
    signer
    Required
    optional
    Type
    array[string]
    Description

    A reference to a signer construct, which will be used to sign the transaction.

Outputs

  • Name
    signed_transaction_bytes
    Type
    addon(svm::transaction)
    Description

    The signed transaction bytes.

Example using sign_transaction

// Coming soon


action

process_instructions

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

Inputs

  • Name
    description
    Required
    optional
    Type
    string
    Description

    A description of the transaction.

  • Name
    instruction
    Required
    required
    Type
    map
    Description

    The instructions to add to the transaction.

  • Name
    signers
    Required
    required
    Type
    array[string]
    Description

    A set of references to signer constructs, which will be used to sign the transaction.

  • Name
    commitment_level
    Required
    optional
    Type
    string
    Description

    The commitment level expected for considering this action as done ('processed', 'confirmed', 'finalized'). The default is 'confirmed'.

  • Name
    rpc_api_url
    Required
    required
    Type
    string
    Description

    The URL to use when making API requests.

  • Name
    rpc_api_auth_token
    Required
    optional
    Type
    string
    Description

    The HTTP authentication token to include in the headers when making API requests.

Outputs

  • Name
    signature
    Type
    string
    Description

    The transaction computed signature.

Example using process_instructions

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]
}


action

deploy_program

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

Inputs

  • Name
    description
    Required
    optional
    Type
    string
    Description

    A description of the deployment action.

  • Name
    program
    Required
    required
    Type
    object
    Description

    The Solana program artifacts to deploy.

  • Name
    payer
    Required
    optional
    Type
    string
    Description

    A reference to a signer construct, which will be used to sign transactions that pay for the program deployment. If omitted, the authority will be used.

  • Name
    authority
    Required
    required
    Type
    string
    Description

    A reference to a signer construct, which will be the final authority for the deployed program.

  • Name
    commitment_level
    Required
    optional
    Type
    string
    Description

    The commitment level expected for considering this action as done ('processed', 'confirmed', 'finalized'). The default is 'confirmed'.

  • Name
    auto_extend
    Required
    optional
    Type
    bool
    Description

    Whether to auto extend the program account for program upgrades. Defaults to true.

Outputs

  • Name
    signatures
    Type
    object
    Description

    The computed transaction signatures, grouped by transaction type.

  • Name
    program_id
    Type
    string
    Description

    The program ID of the deployed program.

  • Name
    program_idl
    Type
    string
    Description

    The program ID of the deployed program.

Example using deploy_program

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
}


action

send_sol

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

Inputs

  • Name
    description
    Required
    optional
    Type
    string
    Description

    A description of the transaction.

  • Name
    amount
    Required
    required
    Type
    integer
    Description

    The amount to send, in lamports (1 SOL = 10^9 lamports).

  • Name
    recipient
    Required
    required
    Type
    string
    Description

    The SVM address of the recipient.

  • Name
    signer
    Required
    required
    Type
    array[string]
    Description

    A reference to a signer construct, which will be used to sign the transaction.

  • Name
    commitment_level
    Required
    optional
    Type
    string
    Description

    The commitment level expected for considering this action as done ('processed', 'confirmed', 'finalized'). The default is 'confirmed'.

  • Name
    rpc_api_url
    Required
    required
    Type
    string
    Description

    The URL to use when making API requests.

  • Name
    rpc_api_auth_token
    Required
    optional
    Type
    string
    Description

    The HTTP authentication token to include in the headers when making API requests.

Outputs

  • Name
    signature
    Type
    string
    Description

    The transaction computed signature.

Example using send_sol

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

action

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
    description
    Required
    optional
    Type
    string
    Description

    A description of the transaction.

  • Name
    amount
    Required
    required
    Type
    integer
    Description

    The amount of tokens to send, in base unit.

  • Name
    token
    Required
    required
    Type
    string
    Description

    The program address for the token being sent. This is also known as the 'token mint account'.

  • Name
    recipient
    Required
    required
    Type
    string
    Description

    The SVM address of the recipient. The associated token account will be computed from this address and the token address.

  • Name
    authority
    Required
    optional
    Type
    string
    Description

    The pubkey of the authority account for the token source. If omitted, the first signer will be used.

  • Name
    fund_recipient
    Required
    optional
    Type
    bool
    Description

    If set to true and the recipient token account does not exist, the action will create the account and fund it, using the signer to fund the account. The default is false.

  • Name
    signers
    Required
    required
    Type
    array[string]
    Description

    A set of references to signer constructs, which will be used to sign the transaction.

  • Name
    commitment_level
    Required
    optional
    Type
    string
    Description

    The commitment level expected for considering this action as done ('processed', 'confirmed', 'finalized'). The default is 'confirmed'.

  • Name
    rpc_api_url
    Required
    required
    Type
    string
    Description

    The URL to use when making API requests.

  • Name
    rpc_api_auth_token
    Required
    optional
    Type
    string
    Description

    The HTTP authentication token to include in the headers when making API requests.

Outputs

  • Name
    signature
    Type
    string
    Description

    The transaction computed signature.

  • Name
    recipient_token_address
    Type
    addon(svm::pubkey)
    Description

    The recipient token account address.

  • Name
    source_token_address
    Type
    addon(svm::pubkey)
    Description

    The source token account address.

  • Name
    token_mint_address
    Type
    addon(svm::pubkey)
    Description

    The token mint address.

Example using send_token

action "send_sol" "svm::send_token" {
    description = "Send some SOL"
    amount = svm::sol_to_lamports(1)
    signers = [signer.caller]
    recipient = "zbBjhHwuqyKMmz8ber5oUtJJ3ZV4B6ePmANfGyKzVGV"
    token = "3bv3j4GvMPjvvBX9QdoX27pVoWhDSXpwKZipFF1QiVr6"
    fund_recipient = true
}

action

deploy_subgraph

svm::deploy_subgraph creates a live Graph QL database for your program.

This command takes a program ID to index, a block height to start indexing from, and a set of events to index. This data is encoded as a request and sent to your surfnet (when deploying to localhost) or to the Surfpool cloud services (when deploying to devnet or mainnet). When the request is received, the associated chain is indexed and the data is stored in a Graph QL database.

Inputs

  • Name
    description
    Required
    optional
    Type
    string
    Description

    A description of the subgraph.

  • Name
    subgraph_name
    Required
    optional
    Type
    string
    Description

    The name of the subgraph. This defaults to the event name.

  • Name
    program_id
    Required
    required
    Type
    string
    Description

    The ID of the program to index as a subgraph.

  • Name
    program_idl
    Required
    required
    Type
    string
    Description

    The IDL of the program, used to decode the data to be indexed.

  • Name
    block_height
    Required
    required
    Type
    integer
    Description

    The block height to start indexing from.

  • Name
    event
    Required
    required
    Type
    map
    Description

    A map of events to index in the subgraph.

Outputs

    Example using deploy_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"
        }
    
    

    action

    setup_surfnet

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

    The current supported operations are to set account or token account data. The set_account action can be used to set the lamports, owner, data, and executable fields of an account. The set_token_account action can be used to set the amount, delegate, delegated amount, and close authority for a token account.

    Inputs

    • Name
      description
      Required
      optional
      Type
      string
      Description

      A description of the setup.

    • Name
      rpc_api_url
      Required
      required
      Type
      string
      Description

      The URL to use when making API requests.

    • Name
      network_id
      Required
      required
      Type
      string
      Description

      The ID of the network type. Can be localnet, devnet, or mainnet-beta.

    • Name
      set_account
      Required
      optional
      Type
      map
      Description

      The account data to set.

    • Name
      set_token_account
      Required
      optional
      Type
      map
      Description

      The token account data to set.

    Outputs

      Example using setup_surfnet

      action "setup" "svm::setup_surfnet" {
          set_account {
              public_key = signer.caller.public_key
              lamports = 999999999
          }
          set_token_account {
              public_key = signer.caller.public_key
              token = "usdc"
              amount = 1000000
          }
      }
      
      

      Was this page helpful?