CrossFi Workshop #1

CrossFi Workshop #1

Smart Contracts on CrossFi Chain

Introduction (5 minutes)

  • Welcome participants to the workshop and introduce the objective: to guide them through deploying a smart contract on the CrossFi Chain.

  • Emphasize that this guide provides a foundational understanding of smart contract deployment, which participants can apply to more complex projects in the future.

  • Highlight the requirements for the workshop: Node.js, basic Solidity understanding, and access to Testnet XFI coins (faucet coming soon).

  • Provide an overview of the tools and technologies used, including Foundry for testing and deployment.

Installing Foundry and Setting Up Project (5 minutes)

  • Explain the importance of Foundry in the deployment process and its role in providing a seamless development experience.

  • Guide participants through creating a project directory and initializing npm using the provided commands.

  • Demonstrate the installation of Foundry using the curl command and running foundryup to set up the environment.

  • Address potential MacOS-specific issues related to library loading and provide a resolution using Homebrew.

Creating and Reviewing the Smart Contract (20 minutes)

  • Instruct participants to create a contract file using the forge init command and open it in their code editor.

  • Review the Counter.sol smart contract, highlighting its components such as the number variable, setNumber and increment functions.

  • Explain the importance of compiling the contract to verify its logic and introduce the forge build command for this purpose.

Testing the Contract (10 minutes)

  • Provide an overview of the provided test file Counter.t.sol and its purpose in ensuring the functionality of the smart contract.

  • Guide participants through executing the test code using the forge test command and interpreting the test results.

  • Emphasize the significance of testing in smart contract development and ensuring the contract behaves as expected.

Deploying the Contract (10 minutes)

  • Explain the deployment process using forge create command, requiring a private key connected to a wallet with Testnet XFI tokens.

  • Provide the necessary parameters including the RPC URL and private key, demonstrating how to deploy the contract.

  • Show participants how to verify the deployment by checking the contract address in the terminal and using the CrossFi Testnet Block Explorer.

Interacting with the Contract (5 minutes)

  • Conclude the workshop by demonstrating contract interaction using Foundry commands.

  • Guide participants through setting the number, reading the current value, and incrementing the number using cast send and cast call commands.

  • Reinforce the completion of the deployment process and encourage participants to explore further contract functionalities independently.

Conclusion (5 minutes)

  • Summarize the key steps covered in the workshop, including project setup, contract creation, testing, deployment, and interaction.

  • Reiterate the applicability of these steps to future CrossFi projects and the importance of understanding smart contract deployment fundamentals.

  • Thank participants for their participation and encourage them to reach out with any questions or feedback.

  • Provide resources for further learning and exploration, such as documentation and community channels.

PreviousPartner Workshop: DIANextCrossFi Workshop #2