Ethereum and EVM Compatible Blockchains (beta) Functions
address
evm::address creates a valid Ethereum address from the input string.
Inputs
- Name
address_string- Required
- optional
- Type
- integer
- Description
An Ethereum address string.
Output
- Name
value- Type
- addon(evm::address)
- Description
The input string as an Ethereum address.
Example using address
output "address" {
value = evm::address("0x627306090abaB3A6e1400e9345bC60c78a8BEf57")
}
zero_address
evm::zero_address is a constant representing the zero address.
Inputs
None
Output
- Name
value- Type
- addon(evm::address)
- Description
The zero address,
0x0000000000000000000000000000000000000000.
Example using zero_address
output "address" {
value = evm::zero_address()
}
to_abi_type
evm::to_abi_type is coming soon
Inputs
- Name
value- Required
- optional
- Type
- string | addon() | array[string]
- Description
Coming soon.
- Name
abi- Required
- optional
- Type
- string
- Description
Coming soon.
- Name
typing- Required
- optional
- Type
- string
- Description
Coming soon.
Output
- Name
value- Type
- addon(evm::bytes32)
- Description
Coming Soon
Example using to_abi_type
abi_encode
evm::abi_encode is coming soon
Inputs
- Name
input- Required
- optional
- Type
- array[string]
- Description
Coming soon.
Output
- Name
value- Type
- addon(evm::bytes32)
- Description
Coming Soon
Example using abi_encode
bytes32
evm::bytes32 encodes a hex string as a 32-byte buffer.
Inputs
- Name
input- Required
- optional
- Type
- string
- Description
A 32-byte hexadecimal string.
Output
- Name
value- Type
- addon(evm::bytes32)
- Description
A 32-byte buffer.
Example using bytes32
output "32_bytes" {
value = evm::bytes32("0123456789012345678901234567890123456789012345678901234567890123")
}
bytes
evm::bytes encodes a hex string as a variable length buffer.
Inputs
- Name
input- Required
- optional
- Type
- string | array[string] | addon() | buffer
- Description
The hex string to encode.
Output
- Name
value- Type
- addon(evm::bytes)
- Description
The input string encoded as a buffer.
Example using bytes
output "bytes" {
value = evm::bytes(encode_hex("Hello, world!"))
}
uint256
evm::uint256 encodes a number as a Solidity uint256 value.
Inputs
- Name
input- Required
- optional
- Type
- string | array[string] | addon() | buffer
- Description
The number to encode.
Output
- Name
value- Type
- addon(evm::uint256)
- Description
The number encoded as a Solidity uint256.
Example using uint256
output "uint256" {
value = evm::uint256(1)
}
uint32
evm::uint32 encodes a number as a Solidity uint32 value.
Inputs
- Name
input- Required
- optional
- Type
- integer
- Description
The number to encode.
Output
- Name
value- Type
- addon(evm::uint32)
- Description
The number encoded as a Solidity uint32.
Example using uint32
output "uint32" {
value = evm::uint32(1)
}
uint8
evm::uint8 encodes a number as a Solidity uint8 value.
Inputs
- Name
input- Required
- optional
- Type
- integer
- Description
The number to encode.
Output
- Name
value- Type
- addon(evm::uint8)
- Description
The number encoded as a Solidity uint8.
Example using uint8
output "uint8" {
value = evm::uint8(1)
}
chain
evm::chain generates a default chain id and RPC API URL for a valid EVM compatible chain name.
Inputs
- Name
input- Required
- optional
- Type
- string
- Description
An EVM-compatible chain name. See https://chainlist.org for a list of supported chains.
Output
- Name
value- Type
- object
- Description
The default chain data.
Example using chain
output "chain_id" {
value = evm::chain("optimism")
}
// > chain_id: 10
get_contract_from_foundry_project
evm::get_contract_from_foundry_project retrieves the compiled contract artifacts for a contract in a Foundry project.
Inputs
- Name
contract_name- Required
- required
- Type
- string
- Description
The name of the contract being deployed.
- Name
contract_filename- Required
- optional
- Type
- string
- Description
The
.solfile that the contract is located in. Defaults to<ContractName>.sol.
- Name
foundry_manifest_path- Required
- optional
- Type
- string
- Description
The location of the Foundry.toml. Defaults to
./foundry.toml.
- Name
foundry_profile- Required
- optional
- Type
- string
- Description
The foundry profile that should be used to find the compiled output. Defaults to
default.
Output
- Name
value- Type
- object
- 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
}
get_contract_from_hardhat_project
evm::get_contract_from_hardhat_project retrieves the compiled contract artifacts for a contract in a Hardhat project.
Inputs
- Name
contract_name- Required
- required
- Type
- string
- Description
The name of the contract being deployed.
- Name
contract_source_path- Required
- optional
- Type
- string
- Description
The path, relative to the Hardhat project root, to the contract source file. Defaults to
./contracts/<ContractName>.sol.
- Name
artifacts_path- Required
- optional
- Type
- string
- Description
The path to the Hardhat artifacts directory. Defaults to
./artifacts.
Output
- Name
value- Type
- object
- 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
}
create_init_code
Coming soon
Inputs
- Name
bytecode- Required
- optional
- Type
- string | addon(evm::foundry_bytecode_data)
- Description
Coming Soon
- Name
constructor_args- Required
- optional
- Type
- array[string]
- Description
Coming Soon
- Name
linked_libraries- Required
- optional
- Type
- object
- Description
Coming Soon
Output
- Name
value- Type
- addon(evm::init_code)
- Description
Coming Soon
Example using create_init_code
// Coming Soon
encode_function_call
Coming soon
Inputs
- Name
function_name- Required
- required
- Type
- string
- Description
Coming Soon
- Name
function_args- Required
- required
- Type
- array[string] | array[integer] | array[addon(evm::address)]
- Description
Coming Soon
- Name
abi- Required
- optional
- Type
- string
- Description
Coming Soon
Output
- Name
value- Type
- addon(evm::function_call)
- Description
Coming Soon
Example using encode_function_call
// Coming Soon
create2
Coming soon
Inputs
- Name
salt- Required
- optional
- Type
- string
- Description
Coming Soon
- Name
init_code- Required
- optional
- Type
- addon(evm::init_code) | string
- Description
Coming Soon
- Name
create2_factory_contract_address- Required
- optional
- Type
- addon(evm::address) | string
- Description
Coming Soon
Output
- Name
value- Type
- object
- Description
Coming Soon
Example using create2
// Coming Soon