Ethereum and EVM Compatible Blockchains (beta) Functions

function

address

evm::address creates a valid Ethereum address from the input string.

Inputs

  • Name
    address_string
    Description

    An Ethereum address string.

Output

  • Name
    value
    Description

    The input string as an Ethereum address.

Example using address

output "address" { 
    value = evm::address("0x627306090abaB3A6e1400e9345bC60c78a8BEf57")
}


function

zero_address

evm::zero_address is a constant representing the zero address.

Inputs

    Output

    • Name
      value
      Description

      The zero address, 0x0000000000000000000000000000000000000000.

    Example using zero_address

    output "address" { 
        value = evm::zero_address()
    }
    
    

    function

    bytes32

    evm::bytes32 encodes a hex string as a 32-byte buffer.

    Inputs

    • Name
      input
      Description

      A 32-byte hexadecimal string.

    Output

    • Name
      value
      Description

      A 32-byte buffer.

    Example using bytes32

    output "32_bytes" {
        value = evm::bytes32("0123456789012345678901234567890123456789012345678901234567890123")
    }
    
    

    function

    bytes

    evm::bytes encodes a hex string as a variable length buffer.

    Inputs

    • Name
      input
      Description

      The hex string to encode.

    Output

    • Name
      value
      Description

      The input string encoded as a buffer.

    Example using bytes

    output "bytes" {
        value = evm::bytes(encode_hex("Hello, world!"))
    }
    
    

    function

    uint32

    evm::uint32 encodes a number as a Solidity uint32 value.

    Inputs

    • Name
      input
      Description

      The number to encode.

    Output

    • Name
      value
      Description

      The number encoded as a Solidity uint32.

    Example using uint32

    output "uint32" {
        value = evm::uint32(1)
    }
    
    

    function

    uint8

    evm::uint8 encodes a number as a Solidity uint8 value.

    Inputs

    • Name
      input
      Description

      The number to encode.

    Output

    • Name
      value
      Description

      The number encoded as a Solidity uint8.

    Example using uint8

    output "uint8" {
        value = evm::uint8(1)
    }
    
    

    function

    chain

    evm::chain generates a default chain id and RPC API URL for a valid EVM compatible chain name.

    Inputs

    • Name
      input
      Description

      An EVM-compatible chain name. See https://chainlist.org for a list of supported chains.

    Output

    • Name
      value
      Description

      The default chain data.

    Example using chain

    output "chain_id" {
        value = evm::chain("optimism")
    }
    // > chain_id: 10
    
    

    function

    get_contract_from_foundry_project

    evm::get_contract_from_foundry_project retrieves the deployment artifacts for a contract in a Foundry project.

    Inputs

    • Name
      contract_name
      Description

      The name of the contract being deployed.

    • Name
      contract_filename
      Description

      The .sol file that the contract is located in. Defaults to <ContractName>.sol.

    • Name
      foundry_manifest_path
      Description

      The location of the Foundry.toml. Defaults to ./foundry.toml.

    • Name
      foundry_profile
      Description

      The foundry profile that should be used to find the compiled output. Defaults to default.

    Output

    • Name
      value
      Description

      Coming Soon

    Example using get_contract_from_foundry_project

    variable "contract" {
        value = evm::get_contract_from_foundry_project("MyContract")
    }
    output "abi" {
        value = variable.contract.abi
    }        
    
    

    function

    get_contract_from_hardhat_project

    evm::get_contract_from_hardhat_project retrieves the deployment artifacts for a contract in a Hardhat project.

    Inputs

    • Name
      contract_name
      Description

      The name of the contract being deployed.

    • Name
      contract_source_path
      Description

      The path, relative to the Hardhat project root, to the contract source file. Defaults to ./contracts/<ContractName>.sol.

    • Name
      artifacts_path
      Description

      The path to the Hardhat artifacts directory. Defaults to ./artifacts.

    Output

    • Name
      value
      Description

      Coming Soon

    Example using get_contract_from_hardhat_project

    variable "contract" {
        value = evm::get_contract_from_hardhat_project("MyContract")
    }
    output "abi" {
        value = variable.contract.abi
    } 
    
    

    function

    create_init_code

    Coming soon

    Inputs

    • Name
      bytecode
      Description

      Coming Soon

    • Name
      constructor_args
      Description

      Coming Soon

    Output

    • Name
      value
      Description

      Coming Soon

    Example using create_init_code

    // Coming Soon
    
    

    function

    encode_function_call

    Coming soon

    Inputs

    • Name
      function_name
      Description

      Coming Soon

    • Name
      function_args
      Description

      Coming Soon

    • Name
      abi
      Description

      Coming Soon

    Output

    • Name
      value
      Description

      Coming Soon

    Example using encode_function_call

    // Coming Soon
    
    

    function

    create2

    Coming soon

    Inputs

    • Name
      salt
      Description

      Coming Soon

    • Name
      init_code
      Description

      Coming Soon

    • Name
      create2_factory_contract_address
      Description

      Coming Soon

    Output

    • Name
      value
      Description

      Coming Soon

    Example using create2

    // Coming Soon
    
    

    Was this page helpful?