Skip to content

OffchainLabs/stylus-workshop-counter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stylus workshop: Counter contract

Simple Counter contract written in Rust.

Getting started

Follow the instructions in the Stylus quickstart to configure your development environment.

You'll also need Foundry to interact with the contract.

Check and deploy

You can use cargo stylus to check that your contract is compatible with Stylus by running

cargo stylus check

With the following command you can deploy it to an Arbitrum chain

cargo stylus deploy --endpoint $RPC_URL --private-key $PRIVATE_KEY

Alternatively, you can use the bash scripts available to build and deploy the contract:

  • build.sh
  • deploy.sh: this script requires the environment variables $RPC_URL and $PRIVATE_KEY.

Tests

For unit testing, this example integrates the motsu library from OpenZeppelin. To run unit tests, you can simply use

cargo test --locked --lib

Alternatively, you can use the bash script available test-unit.sh.

For integration tests, this example integrates a fork of the e2e library from OpenZeppelin available here. To run the tests you need to run a nitro-testnode. A script is available to clone and run the nitro-testnode, nitro-testnode.sh. Once the nitro-testnode is running, you can run the e2e tests using the script available test-e2e.sh.

Additional scripts

The scripts folder contains several other scripts that make individual calls to perform the most important actions:

  1. ./scripts/getCount.sh to get the current counter
  2. ./scripts/increment.sh to increment the current counter
  3. ./scripts/setCount.sh to set the current counter

Remember to set the environment variables in an .env file.

How to run a local dev node

Instructions to setup a local dev node can be found here.

Useful resources

Stylus reference links

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published