Solidity
Solidity is statically typed, supports inheritance, libraries, and complex user-defined types, among other features.
Contract language for voting, auctions, multi-sig wallets, etc. Contract is collection of functions and data stored on blockchain.
Functions that aren't pure/view cost gas
Account have storage which is persistent between function calls/transcations. Memory for each call.
Foundry
Smart contract development toolchain with building, testing, etc
curl -L https://foundry.paradigm.xyz | bashFollow instructions perhaps
foundryupSolidity
Basic Program
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.4;
contract Coin {
// public variables accessible from other contracts
address public minter;
mapping(address => uint) public balances;
// Events are subscribeable by clients
event Sent(address from, address to, uint amount);
constructor() {
minter = msg.sender;
}
function mint(address receiver, uint amount) public {
require(msg.sender == minter);
balances[receiver] += amount;
}
error InsufficientBalance(uint requested, uint available);
function send(address receiver, uint amount) public {
if (amount > balances[msg.sender])
revert InsufficientBalance({
requested: amount,
available: balances[msg.sender]
});
balances[msg.sender] -= amount;
balances[receiver] += amount;
emit Sent(msg.sender, receiver, amount);
}
}Variable Visibility
Function Modifiers
Custom Modifer
Mapping
Enum
Custom Error
Foundry Unit Tests
Last updated