DeveloperBreeze

Smart Contracts Programming Tutorials, Guides & Best Practices

Explore 7+ expertly crafted smart contracts tutorials, components, and code examples. Stay productive and build faster with proven implementation strategies and design patterns from DeveloperBreeze.

Cheatsheet
solidity

Solidity Cheatsheet

  • revert: Explicitly reverts the transaction, optionally providing an error message.

function withdraw(uint _amount) public {
    require(_amount <= balances[msg.sender], "Insufficient balance");
    balances[msg.sender] -= _amount;
}

function divide(uint a, uint b) public pure returns (uint) {
    assert(b != 0);
    return a / b;
}

function doSomething(uint _value) public {
    if (_value < 10) {
        revert("Value too low");
    }
}

Aug 22, 2024
Read More