Skip to content

Latest commit

 

History

History
54 lines (43 loc) · 5.3 KB

File metadata and controls

54 lines (43 loc) · 5.3 KB
title slug
Introduction
/writing-contracts

Writing On-Chain Code

This section shows you how to write session code and smart contracts in Rust and WebAssembly (Wasm) for a Casper network. When referring to session code, these documents outline logic that executes in the context of an account. In contrast, smart contracts consist of logic installed on-chain, for use by multiple parties. There is a large overlap between the processes of writing session code versus contract code, with some semantic differences outlined in their respective documentation. The Video Series for Writing On-Chain Code accompanies the topics below.

<iframe width="400" height="225" src="https://www.youtube.com/embed/JoOjhSOnQzk" position="middle" frameborder="0" allow="accelerometer; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

Title Description
Getting Started with Rust An introduction to using Rust with the Casper Platform
Writing a Basic Smart Contract in Rust An example of a smart contract built in Rust
Unit Testing Smart Contracts Steps to test contract code using the unit testing framework
Upgrading and Maintaining Smart Contracts An introduction to versioning smart contracts
Calling Contracts
Smart Contracts and Session Code Understand what session code is and when you would use it over contract code
Writing Session Code An introduction to writing session code
Unit Testing Session Code Steps to test session code using the unit testing framework
Contract-Level Events Enabling smart contracts to emit messages while executing on the blockchain
Using Contract Hash vs. Package Hash Advantages and disadvantages of using contract_hash vs. contract_package_hash when calling a contract
The Factory Pattern for Smart Contracts Learn to implement the contract factory pattern on a Casper network
Best Practices for Casper Smart Contract Authors An outline of best practices when developing smart contracts on a Casper network

Interacting with Contracts on the Blockchain

Additionally, the section on Interacting with the Blockchain covers installing and calling contracts using the Casper command-line client written in Rust.

Title Description
Installing Smart Contracts and Querying Global State A guide on installing smart contracts and querying global state
Calling Smart Contracts with the Rust Client Steps to call a smart contract with the Rust command-line client
Reading and Writing to Dictionaries Information on Dictionaries and how to read and write to them on the Casper Platform.
Execution Error Codes Possible error codes when writing smart contracts.

Tutorials

The following tutorials outline some aspects of writing smart contracts on a Casper network.

Title Description
Getting Started Video Step-by-step video tutorial for setting up the Casper development environment
A Counter on the Testnet An example contract that maintains a counter variable on the Casper Testnet
Smart Contract Upgrades Learn how to upgrade smart contracts
NFTs on Casper with the CEP-78 NFT Standard Implementing the Casper CEP-78 NFT standard
Fungible Tokens on Casper Implement the Casper Fungible Token standard
Interacting with Runtime Return Values Learning how to return a value using contract code
Working with Authorization Keys Retrieving and using the authorization keys associated with a transaction
Safely Transfer Tokens to a Contract How to handle tokens via a contract