Solana and SVM Compatible Blockchains (alpha) Functions

function

system_program_id

svm::system_program_id returns the id of the system program, 11111111111111111111111111111111.

Inputs

    Output

    • Name
      value
      Description

      The system program id

    Example using system_program_id

    output "system_program_id" { 
        value = svm::system_program_id()
    }
    // > 11111111111111111111111111111111
    
    

    function

    account

    svm::account encodes a public key in to an account meta object for a program instruction call.

    Inputs

    • Name
      public_key
      Description

      The on-chain address of an account.

    • Name
      is_signer
      Description

      Specify if the account is required as a signer on the transaction.

    • Name
      is_writable
      Description

      Specify if the account data will be modified.

    Output

    • Name
      value
      Description

      The account meta object.

    Example using account

    output "account" { 
        value = svm::account("3z9vL1zjN6qyAFHhHQdWYRTFAcy69pJydkZmSFBKHg1R", true, true)
    }
    // > account: { public_key: 3z9vL1zjN6qyAFHhHQdWYRTFAcy69pJydkZmSFBKHg1R, is_signer: true, is_writable: true } 
    
    

    function

    get_instruction_data_from_idl_path

    svm::get_instruction_data_from_idl_path creates encoded instruction data for a program invocation, providing type checking and serialization based on the provided IDL file.

    Inputs

    • Name
      idl_path
      Description

      The path, relative to the txtx.yml, to the IDL .json file.

    • Name
      instruction_name
      Description

      The name of the instruction to generate data for, as indexed by the IDL.

    • Name
      arguments
      Description

      The instruction arguments to generate data for.

    Output

    • Name
      value
      Description

      The encoded instruction data.

    Example using get_instruction_data_from_idl_path

    output "data" {
        value = svm::get_instruction_data_from_idl("/path/to/idl.json", "my_instruction", ["arg1", "arg2"])
    }
    // > data: 0x95763bdcc47fa1b305000000776f726c64
    
    

    function

    get_instruction_data_from_idl

    svm::get_instruction_data_from_idl_path creates encoded instruction data for a program invocation, providing type checking and serialization based on the provided IDL data.

    Inputs

    • Name
      idl
      Description

      The program IDL.

    • Name
      instruction_name
      Description

      The name of the instruction to generate data for, as indexed by the IDL.

    • Name
      arguments
      Description

      The instruction arguments to generate data for.

    Output

    • Name
      value
      Description

      The encoded instruction data.

    Example using get_instruction_data_from_idl

    output "data" {
        value = svm::get_instruction_data_from_idl(variable.idl, "my_instruction", ["arg1", "arg2"])
    }
    // > data: 0x95763bdcc47fa1b305000000776f726c64
    
    

    function

    get_program_from_anchor_project

    svm::get_program_from_anchor_project retrieves the program deployment artifacts for a program in an Anchor project.

    Inputs

    • Name
      program_name
      Description

      The name of the program being deployed.

    • Name
      target_path
      Description

      The target path to the compiled anchor project artifacts. Defaults to ./target.

    Output

    • Name
      value
      Description

      An object containing the anchor program artifacts.

    Example using get_program_from_anchor_project

    variable "contract" {
        value = evm::get_program_from_anchor_project("my_program")
    }
    output "idl" {
        value = variable.contract.idl
    }    
    
    

    Was this page helpful?