Arbitrum Stylus logo

Stylus by Example

Vending Machine

An example project for writing Arbitrum Stylus programs in Rust using the stylus-sdk. It includes a Rust implementation of a vending machine Ethereum smart contract.

  • distribute Cupcakes to any given address
  • count Cupcakes balance of any given address

Here is the interface for Vending Machine.

1interface IVendingMachine {
2    // Function to distribute a cupcake to a user
3    function giveCupcakeTo(address userAddress) external returns (bool);
4
5    // Getter function for the cupcake balance of a user
6    function getCupcakeBalanceFor(address userAddress) external view returns (uint);
7}
1interface IVendingMachine {
2    // Function to distribute a cupcake to a user
3    function giveCupcakeTo(address userAddress) external returns (bool);
4
5    // Getter function for the cupcake balance of a user
6    function getCupcakeBalanceFor(address userAddress) external view returns (uint);
7}

Example implementation of the Vending Machine contract written in Rust.

src/lib.rs

1Loading...
1Loading...

Cargo.toml

1Loading...
1Loading...

src/main.rs

1Loading...
1Loading...