Closed
Milestone
Apr 21, 2025–Jul 4, 2025
Tezlink: smart contracts
Context
In the previous milestone, we added support in Tezlink for implicit accounts. This milestone is about adding basic support for smart contracts.
The goal of this milestone is an end-to-end test using octez-client in which:
- the chain is bootstrapped with a simple contract, for example
michelson_test_scripts/opcodes/concat_hello.tz, - we use
octez-client get contract storageto check that the storage is the initial storage, - we use
octez-client transferto call the contract with parameter{"world"}, - we use
octez-client get contract storageto check that the storage is now{"Hello world"}.
This milestone requires adding MIR to the dependencies of the kernel and using the MIR interpreter to execute the script of the smart contract but many Michelson-related features are out of the scope of the milestone, notably:
- inter-contract calls,
- contract origination,
- big maps.
Work breakdown
- add a new kind of accounts (smart contracts, whose addresses start with "KT1"),
- add bootstrap smart contracts, @luciano.freitas !18042 (merged)
- add support for the rpc called by
octez-client get contract storage, @brahima.dibassi !18055 (closed) - extend the transfer operation to perform smart-contract calls,
- add a
parametersfield toTransactionContentof typeOption<(mir::michelson_address::entrypoint, Vec<u8>)>, - modify application of transactions to:
- deserialize the argument using
Micheline::decode_raw, - deserialize the contract storage using
Micheline::decode_raw, - execute the contract, (inspiration source:
mainincontrib/mir/examples/call_entrypoint.rs), - check that no internal operation were produced,
- serialize the new contract storage,
- store the new contract storage.
- deserialize the argument using
- add a
- end-to-end test.
Demo setup
The following commands should be invoked from the tezos directory:
# Clean up previous runs
rm -rf /tmp/demo
# Create temporary folders for the demo
mkdir -p /tmp/demo/wallet
mkdir /tmp/demo/sandbox
# Create kernel configuration for tezlink contaning bootstrap accounts and smart contracts
./octez-evm-node make l2 kernel installer config /tmp/demo/l2-12-config.yaml --l2-chain-id 12 --l2-chain-family Michelson --tez-bootstrap-balance 3800000 --tez-bootstrap-account edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav --tez-bootstrap-contract 'KT1Q36KWPSba7dHsH5E4ZsQHehrChc51e19d,0x02000000170500036805010368050202000000080316053d036d0342,0x0100000007696e697469616c'
# Create the kernel
./smart-rollup-installer get-reveal-installer --upgrade-to evm_kernel.wasm --output /tmp/demo/evm_kernel-installer.hex --preimages-dir /tmp/demo/wasm_2_0_0 --setup-file /tmp/demo/l2-12-config.yaml
# Configure a sequencer node with relay RPC node to treat requests
./octez-evm-node init config --sequencer-key unencrypted:edsk3tNH5Ye6QaaRQev3eZNcXgcN6sjCJRXChYFz42L6nKfRVwuL1n --preimages-dir /tmp/demo/wasm_2_0_0 --private-rpc-port 51371 --wallet-dir /tmp/demo/wallet --data-dir /tmp/demo/sandbox --rpc-port 46083
# Launch sandbox
./octez-evm-node run tezlink sandbox --kernel /tmp/demo/evm_kernel-installer.hex --wallet-dir /tmp/demo/wallet --data-dir /tmp/demo/sandbox --rpc-port 46083
# Simplify repetitive commands
alias tezlink_client='./octez-client --endpoint http://127.0.0.1:46083/tezlink --wait none --base-dir /tmp/demo/wallet'
# Import bootstrap secret key
tezlink_client import secret key alice unencrypted:edsk3gUfUPyBSfrS9CCgmCiQsTCHGkviBDusMxDJstFtojtc1zcpsh
# Save echo contract
tezlink_client remember contract echo KT1Q36KWPSba7dHsH5E4ZsQHehrChc51e19d
# Fetch the initial storage of the contract, should return `"initial"`
tezlink_client get contract storage for echo
# Make a transfer to the contract, executing it
tezlink_client -l transfer 10 from alice to echo --burn-cap 1 --arg '"Hello World"'
# Fetch the post-execution storage of the contract, should return `"Hello World"`
tezlink_client get contract storage for echo
Loading
Loading
Loading
Loading