Ethereum and EVM Compatible Blockchains (beta) Functions
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")
}
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")
}
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!"))
}
chain
evm::chain
generates a default chain id and RPC API URL for a valid EVM compatible chain name.
Inputs
- Name
input
- Description
A 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
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
}
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
}
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
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