<aside> 💡 This is still very hacky, and YMMV. Thanks to Kobi’s initial work here.

</aside>

Instructions

In general, we’ll follow the Risc0 Bonsai Foundry Template instructions, calling out differences in this document.

  1. Clone this forked repo, checkout the scroll-sepolia-deployment branch, then following the instructions for a normal bonsai deployment to install dependencies.

    GitHub - dghelm/bonsai-foundry-template at scroll-sepolia-deployment

    <aside> ⚠️ Be sure to checkout the scroll-sepolia-deployment branch before installing! Please confirm that lib/bonsai/ethereum/contracts/ISHA256.sol exists in your project, if not, run git submodule update --remote lib/risc0 to make sure your project is using the latest commit of the Scroll Sepolia risc0 fork.

    </aside>

  2. Run cp .env.example .env and place your own values in the .env file. As you update environmental variables with outputs from commands, be sure to run source .env to update these values in your terminal.

  3. Currently, local deployments and tests are untested. But, once you get to the Deploy Your Project page, use the following commands which have been adjusted to use network Scroll specifics.

RISC0_DEV_MODE=false forge script script/Deploy.s.sol --rpc-url $SCROLL_SEPOLIA_RPC_HTTPS --broadcast --legacy

(After deploying the contracts, update your environmental variables.)

RISC0_DEV_MODE=false cargo run --bin bonsai-ethereum-relay-cli -- run --relay-address $BONSAI_RELAY_ADDRESS --eth-node $SCROLL_SEPOLIA_RPC_WSS  --eth-chain-id $DEPLOY_BONSAI_TEST_RELAY_EXPECTED_CHAIN_ID  --private-key $DEPLOYER_PRIVATE_KEY --bonsai-api-url $BONSAI_API_URL --bonsai-api-key $BONSAI_API_KEY
cargo run --example offchain_request $APP_ADDRESS 10 --bonsai-api-key $BONSAI_API_KEY
cast call --rpc-url $SCROLL_SEPOLIA_RPC_HTTPS $APP_ADDRESS 'fibonacci(uint256)' 10

cast send --rpc-url $SCROLL_SEPOLIA_RPC_HTTPS --private-key $DEPLOYER_PRIVATE_KEY --gas-limit 100000 $APP_ADDRESS 'calculateFibonacci(uint256)' 5 --legacy
cast call --rpc-url $SCROLL_SEPOLIA_RPC_HTTPS $APP_ADDRESS 'fibonacci(uint256)' 5

<aside> ⚠️ Contract verification on sepolia.scrollscan.com seems to not work for these contracts. If you get it working, please let us know.

</aside>

Changes

In general, most of the code changes needed for deploying Bonsai on Scroll were in the risc0/risc0 monorepo. The main change was changing every use of the sha256 precompile and instead pointing it to a smart-contract on Scroll Sepolia that could do the same calculation. This was mostly a process of identifying every call in Solidity to sha256() and replacing it with a sha256Hasher.hash() method referencing that smart contract.

In the bonsai-foundry-template repo, the main differences were:

  1. Updating git submodule to point at my dghelm/risc0 fork
  2. Updating the feature flags for the relay’s ethers-rs dependency to support legacy tx types.