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.

  • Name
    pre_condition
    Required
    optional
    Type
    map
    Description

    Pre-conditions are assertions that are evaluated before a command is executed. They can be used to determine if the command should be executed or if a specific behavior should be executed based on the result of the assertion. This is a map type containing the keys:

    • behavior: The behavior if the pre-condition assertion does not pass. Possible values are:

      • halt (default): Throws an error and halts execution of the runbook
      • log: Logs a warning and continues execution of the runbook
      • skip: Skips execution of this command and all downstream commands
    • assertion: The assertion to check to determine if the pre-condition behavior should be executed. This value should evaluate to a boolean, or the std::assert_eq and other assertions from the standard library can be used.

  • Name
    post_condition
    Required
    optional
    Type
    map
    Description

    Post-conditions are assertions that are evaluated after a command is executed. They can be used to determine if the command should be re-executed or if a specific behavior should be executed based on the result of the assertion. This is a map type containing the keys:

    • retries: If the post-condition assertion fails, the number of times to re-execute the command before executing the post-condition behavior. The default is 0.

    • backoff_ms: If the post-condition assertion fails, the number of milliseconds to wait before re-executing the command. If not specified, the default is 1000 milliseconds (1 second).

    • behavior: The behavior if the post-condition assertion does not pass. Possible values are:

      • halt (default): Throws an error and halts execution of the runbook
      • log: Logs a warning and continues execution of the runbook
      • skip: Skips execution of this command and all downstream commands
      • continue: Continues execution without any action
    • assertion: The assertion to check to determine if the command should be re-executed or if the post-condition behavior should be executed. This value should evaluate to a boolean, or the std::assert_eq and other assertions from the standard library can be used.

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. This is a map type containing the keys:

    • raw_bytes: The serialized instruction bytes. Use this field in place of the other instructions if direct instruction bytes would like to be used.
    • program_id: The SVM address of the program being invoked. If omitted, the program_id will be pulled from the idl.
    • program_idl: The IDL of the program being invoked.
    • instruction_name: The name of the instruction being invoked.
    • instruction_args: The arguments to the instruction being invoked.
  • 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.

  • Name
    pre_condition
    Required
    optional
    Type
    map
    Description

    Pre-conditions are assertions that are evaluated before a command is executed. They can be used to determine if the command should be executed or if a specific behavior should be executed based on the result of the assertion. This is a map type containing the keys:

    • behavior: The behavior if the pre-condition assertion does not pass. Possible values are:

      • halt (default): Throws an error and halts execution of the runbook
      • log: Logs a warning and continues execution of the runbook
      • skip: Skips execution of this command and all downstream commands
    • assertion: The assertion to check to determine if the pre-condition behavior should be executed. This value should evaluate to a boolean, or the std::assert_eq and other assertions from the standard library can be used.

  • Name
    post_condition
    Required
    optional
    Type
    map
    Description

    Post-conditions are assertions that are evaluated after a command is executed. They can be used to determine if the command should be re-executed or if a specific behavior should be executed based on the result of the assertion. This is a map type containing the keys:

    • retries: If the post-condition assertion fails, the number of times to re-execute the command before executing the post-condition behavior. The default is 0.

    • backoff_ms: If the post-condition assertion fails, the number of milliseconds to wait before re-executing the command. If not specified, the default is 1000 milliseconds (1 second).

    • behavior: The behavior if the post-condition assertion does not pass. Possible values are:

      • halt (default): Throws an error and halts execution of the runbook
      • log: Logs a warning and continues execution of the runbook
      • skip: Skips execution of this command and all downstream commands
      • continue: Continues execution without any action
    • assertion: The assertion to check to determine if the command should be re-executed or if the post-condition behavior should be executed. This value should evaluate to a boolean, or the std::assert_eq and other assertions from the standard library can be used.

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. This is an object type containing the keys:

    • idl: The program idl.
    • binary: The program binary.
    • keypair: The program keypair.
    • program_id: The program id.
  • 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.

  • Name
    pre_condition
    Required
    optional
    Type
    map
    Description

    Pre-conditions are assertions that are evaluated before a command is executed. They can be used to determine if the command should be executed or if a specific behavior should be executed based on the result of the assertion. This is a map type containing the keys:

    • behavior: The behavior if the pre-condition assertion does not pass. Possible values are:

      • halt (default): Throws an error and halts execution of the runbook
      • log: Logs a warning and continues execution of the runbook
      • skip: Skips execution of this command and all downstream commands
    • assertion: The assertion to check to determine if the pre-condition behavior should be executed. This value should evaluate to a boolean, or the std::assert_eq and other assertions from the standard library can be used.

  • Name
    post_condition
    Required
    optional
    Type
    map
    Description

    Post-conditions are assertions that are evaluated after a command is executed. They can be used to determine if the command should be re-executed or if a specific behavior should be executed based on the result of the assertion. This is a map type containing the keys:

    • retries: If the post-condition assertion fails, the number of times to re-execute the command before executing the post-condition behavior. The default is 0.

    • backoff_ms: If the post-condition assertion fails, the number of milliseconds to wait before re-executing the command. If not specified, the default is 1000 milliseconds (1 second).

    • behavior: The behavior if the post-condition assertion does not pass. Possible values are:

      • halt (default): Throws an error and halts execution of the runbook
      • log: Logs a warning and continues execution of the runbook
      • skip: Skips execution of this command and all downstream commands
      • continue: Continues execution without any action
    • assertion: The assertion to check to determine if the command should be re-executed or if the post-condition behavior should be executed. This value should evaluate to a boolean, or the std::assert_eq and other assertions from the standard library can be used.

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.

  • Name
    pre_condition
    Required
    optional
    Type
    map
    Description

    Pre-conditions are assertions that are evaluated before a command is executed. They can be used to determine if the command should be executed or if a specific behavior should be executed based on the result of the assertion. This is a map type containing the keys:

    • behavior: The behavior if the pre-condition assertion does not pass. Possible values are:

      • halt (default): Throws an error and halts execution of the runbook
      • log: Logs a warning and continues execution of the runbook
      • skip: Skips execution of this command and all downstream commands
    • assertion: The assertion to check to determine if the pre-condition behavior should be executed. This value should evaluate to a boolean, or the std::assert_eq and other assertions from the standard library can be used.

  • Name
    post_condition
    Required
    optional
    Type
    map
    Description

    Post-conditions are assertions that are evaluated after a command is executed. They can be used to determine if the command should be re-executed or if a specific behavior should be executed based on the result of the assertion. This is a map type containing the keys:

    • retries: If the post-condition assertion fails, the number of times to re-execute the command before executing the post-condition behavior. The default is 0.

    • backoff_ms: If the post-condition assertion fails, the number of milliseconds to wait before re-executing the command. If not specified, the default is 1000 milliseconds (1 second).

    • behavior: The behavior if the post-condition assertion does not pass. Possible values are:

      • halt (default): Throws an error and halts execution of the runbook
      • log: Logs a warning and continues execution of the runbook
      • skip: Skips execution of this command and all downstream commands
      • continue: Continues execution without any action
    • assertion: The assertion to check to determine if the command should be re-executed or if the post-condition behavior should be executed. This value should evaluate to a boolean, or the std::assert_eq and other assertions from the standard library can be used.

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.

  • Name
    pre_condition
    Required
    optional
    Type
    map
    Description

    Pre-conditions are assertions that are evaluated before a command is executed. They can be used to determine if the command should be executed or if a specific behavior should be executed based on the result of the assertion. This is a map type containing the keys:

    • behavior: The behavior if the pre-condition assertion does not pass. Possible values are:

      • halt (default): Throws an error and halts execution of the runbook
      • log: Logs a warning and continues execution of the runbook
      • skip: Skips execution of this command and all downstream commands
    • assertion: The assertion to check to determine if the pre-condition behavior should be executed. This value should evaluate to a boolean, or the std::assert_eq and other assertions from the standard library can be used.

  • Name
    post_condition
    Required
    optional
    Type
    map
    Description

    Post-conditions are assertions that are evaluated after a command is executed. They can be used to determine if the command should be re-executed or if a specific behavior should be executed based on the result of the assertion. This is a map type containing the keys:

    • retries: If the post-condition assertion fails, the number of times to re-execute the command before executing the post-condition behavior. The default is 0.

    • backoff_ms: If the post-condition assertion fails, the number of milliseconds to wait before re-executing the command. If not specified, the default is 1000 milliseconds (1 second).

    • behavior: The behavior if the post-condition assertion does not pass. Possible values are:

      • halt (default): Throws an error and halts execution of the runbook
      • log: Logs a warning and continues execution of the runbook
      • skip: Skips execution of this command and all downstream commands
      • continue: Continues execution without any action
    • assertion: The assertion to check to determine if the command should be re-executed or if the post-condition behavior should be executed. This value should evaluate to a boolean, or the std::assert_eq and other assertions from the standard library can be used.

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. This is a map type containing the keys:

    • name: The name of the event, as indexed by the IDL, whose occurrences should be added to the subgraph.
    • field: A map of fields to index. This is a map type containing the keys:
      • name: The name of the field as it should appear in the subgraph.
      • description: A description of the field as it should appear in the subgraph schema.
      • idl_key: A key from the event's type in the IDL, indicating which argument from the IDL type to map to this field. By default, the field name is used.
  • Name
    pre_condition
    Required
    optional
    Type
    map
    Description

    Pre-conditions are assertions that are evaluated before a command is executed. They can be used to determine if the command should be executed or if a specific behavior should be executed based on the result of the assertion. This is a map type containing the keys:

    • behavior: The behavior if the pre-condition assertion does not pass. Possible values are:

      • halt (default): Throws an error and halts execution of the runbook
      • log: Logs a warning and continues execution of the runbook
      • skip: Skips execution of this command and all downstream commands
    • assertion: The assertion to check to determine if the pre-condition behavior should be executed. This value should evaluate to a boolean, or the std::assert_eq and other assertions from the standard library can be used.

  • Name
    post_condition
    Required
    optional
    Type
    map
    Description

    Post-conditions are assertions that are evaluated after a command is executed. They can be used to determine if the command should be re-executed or if a specific behavior should be executed based on the result of the assertion. This is a map type containing the keys:

    • retries: If the post-condition assertion fails, the number of times to re-execute the command before executing the post-condition behavior. The default is 0.

    • backoff_ms: If the post-condition assertion fails, the number of milliseconds to wait before re-executing the command. If not specified, the default is 1000 milliseconds (1 second).

    • behavior: The behavior if the post-condition assertion does not pass. Possible values are:

      • halt (default): Throws an error and halts execution of the runbook
      • log: Logs a warning and continues execution of the runbook
      • skip: Skips execution of this command and all downstream commands
      • continue: Continues execution without any action
    • assertion: The assertion to check to determine if the command should be re-executed or if the post-condition behavior should be executed. This value should evaluate to a boolean, or the std::assert_eq and other assertions from the standard library can be used.

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. This is a map type containing the keys:

      • public_key: The public key of the account to set.
      • lamports: The amount of lamports the account should be set to have.
      • data: The data to set in the account.
      • owner: The owner to set for the account.
      • executable: The executability state to set for the account.
      • rent_epoch: The epoch at which the account will be rent-exempt.
    • Name
      set_token_account
      Required
      optional
      Type
      map
      Description

      The token account data to set. This is a map type containing the keys:

      • public_key: The public key of the token owner account to update.
      • token: The token symbol or public key for the token.
      • token_program: The token program id. Valid values are token2020, token2022, or a public key.
      • amount: The amount of tokens to set.
      • delegate: The public key of the delegate to set.
      • delegated_amount: The amount of tokens to delegate.
      • close_authority: The public key of the close authority to set.
      • state: The state of the token account. Valid values are initialized, frozen, or uninitialized.
    • Name
      clone_program_account
      Required
      optional
      Type
      map
      Description

      The program clone data to set. This is a map type containing the keys:

      • source_program_id: The public key of the program to clone.
      • destination_program_id: The destination public key of the program.
    • Name
      pre_condition
      Required
      optional
      Type
      map
      Description

      Pre-conditions are assertions that are evaluated before a command is executed. They can be used to determine if the command should be executed or if a specific behavior should be executed based on the result of the assertion. This is a map type containing the keys:

      • behavior: The behavior if the pre-condition assertion does not pass. Possible values are:

        • halt (default): Throws an error and halts execution of the runbook
        • log: Logs a warning and continues execution of the runbook
        • skip: Skips execution of this command and all downstream commands
      • assertion: The assertion to check to determine if the pre-condition behavior should be executed. This value should evaluate to a boolean, or the std::assert_eq and other assertions from the standard library can be used.

    • Name
      post_condition
      Required
      optional
      Type
      map
      Description

      Post-conditions are assertions that are evaluated after a command is executed. They can be used to determine if the command should be re-executed or if a specific behavior should be executed based on the result of the assertion. This is a map type containing the keys:

      • retries: If the post-condition assertion fails, the number of times to re-execute the command before executing the post-condition behavior. The default is 0.

      • backoff_ms: If the post-condition assertion fails, the number of milliseconds to wait before re-executing the command. If not specified, the default is 1000 milliseconds (1 second).

      • behavior: The behavior if the post-condition assertion does not pass. Possible values are:

        • halt (default): Throws an error and halts execution of the runbook
        • log: Logs a warning and continues execution of the runbook
        • skip: Skips execution of this command and all downstream commands
        • continue: Continues execution without any action
      • assertion: The assertion to check to determine if the command should be re-executed or if the post-condition behavior should be executed. This value should evaluate to a boolean, or the std::assert_eq and other assertions from the standard library can be used.

    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
          }
          clone_program_account {
              source_program_id = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" // USDC program id
              destination_program_id = variable.my_program_id
          }
      }
      
      

      Was this page helpful?