This project demonstrates how to use hardhat or foundry to deploy a contract in Scroll's rollup network. This project contains a simple contract that will lock a certain amount of Ether in the deployed contract for a specified amount of time.
- Access to Scroll's Pre-Alpha Testnet: https://prealpha.scroll.io
- Network setup: https://guide.scroll.io/user-guide/setup
- If you haven't already, install nodejs and yarn.
- Run
yarn installto install dependencies. - Create a
.envfile following the example.env.examplein the root directory. ChangePRIVATE_KEYto your own account private key in the.env. - Run
yarn compileto compile the contract. - Run
yarn deploy:scrollTestnetto deploy the contract on the Scroll Pre-Alpha Testnet. - Run
yarn testfor hardhat tests.
- Install Foundry.
curl -L https://foundry.paradigm.xyz | bash foundryup - Build the project.
forge build - Deploy the contract.
forge create --rpc-url https://prealpha.scroll.io/l2 \ --value <lock_amount> \ --constructor-args <unlock_time> \ --private-key <your_private_key> \ --legacy \ contracts/Lock.sol:Lock
<lock_amount>is the amount ofTSETHto be locked in the contract. Try setting this to some small amount, like0.0000001ether.<unlock_time>is the Unix timestamp after which the funds locked in the contract will become available for withdrawal. Try setting this to some Unix timestamp in the future, like1696118400(this Unix timestamp corresponds to October 1, 2023).
For example:
forge create --rpc-url https://prealpha.scroll.io/l2 --value 0.00000000002ether --constructor-args 1696118400 --private-key 0xabc123abc123abc123abc123abc123abc123abc123abc123abc123abc123abc1 --legacy contracts/Lock.sol:Lock
Join our Discord: https://scroll.io/