Table of Contents
- Preparing a development environment
- Deploying a smart contract
- Testing the smart contract
Preqrequisites
-
Prepare Dev Environemnt
- Ensure you have Rust installed on your machine.
- Install Foundry if you do not have it installed on your machine
-
Create a New Foundry Project
Run the following in your terminal: -
Modify Foundry Configuration
Update thefoundry.tomlfile to add SKALE Europa Testnet -
The Smart Contract
Smart contracts are created under thesrcfolder. There is already aCounter.solcontract in the project located atsrc/Counter.sol.This smart contract has two publicwritefunctions and 1 publicreadfunction. The write functions aresetNumberandincrementwhich allow the sender to set any number of increment by one (1) respectivley. The read function allows anyone to read the current number set in the contract. -
Compile the Smart Contract
Compilation is the process of taking Solidity smart contracts in thesrcfolder and compiling them to EVM compatible bytecode and ABIs which offchain programs use to interact with the smart contract. You can find the output of the compilation process in theoutfolder. -
Prepare Signer for Deployment
This tutorial uses the Foundry Keystore for increased security. You can optionally fill up your own wallet with sFUEL, and set the private key in commands using —private key [your-private-key], however, this is not recommended. Start by creating a new keystore:The above command:- Generates a new private key
- Imports the private key into a keystore file named
skale-deployer - Prints the address of the newly created wallet to the console
Copy the address from your console and head over to the sFUEL Station. Input the address, toggle testnet, and fill up on Europa Testnet (the blue one). -
Deploy the Smart Contract
To deploy theCounter.solsmart contract, run the following and enter your keystore deployer password:A successful deployment should look something like this: -
Verify your Smart Contract
To verify your smart contract, run the following in your terminal:
Next Steps
Great work! You successfully deployed your first contract to SKALE making use of the zero gas fees and a number of popular tools.Continue Learning
Using Filestorage
Store files and websites onchain
SKALE Bridge
Bridge assets between chains
Random Number Generation
Use onchain randomness in your dApp
Gas and Compute
Learn about gas models on SKALE
Resources
- Foundry Documentation - Learn more about Foundry
- SKALE Discord - Join the community for support
- Build a dApp - Complete guide to building on SKALE
