Free Cheat Sheet — Updated April 2026

Smart Contract Cheat Sheet — Go, JS, Java & Solidity

Side-by-side CRUD patterns for Fabric chaincode and Besu smart contracts. Working code examples, testing templates, and the 5 anti-patterns that break production.

Different platforms, different languages, same mistakes

Developers waste hours translating patterns between Fabric's Go/JS/Java chaincode and Besu's Solidity contracts. The APIs are different, the state models are different, the testing tools are different — but the CRUD patterns are the same. This cheat sheet puts them side by side.

Fabric — Go Chaincode
// Fabric Chaincode — Go (asset CRUD)
func (c *AssetContract) CreateAsset(ctx contractapi.TransactionContextInterface,
    id, name, owner string, value int) error {

    exists, err := c.AssetExists(ctx, id)
    if err != nil {
        return fmt.Errorf("failed to check existence: %w", err)
    }
    if exists {
        return fmt.Errorf("asset %s already exists", id)
    }

    asset := Asset{ID: id, Name: name, Owner: owner, Value: value}
    assetJSON, err := json.Marshal(asset)
    if err != nil {
        return fmt.Errorf("failed to marshal: %w", err)
    }

    return ctx.GetStub().PutState(id, assetJSON)
}
See all 4 languages side by side
Besu — Solidity Contract
// Besu Smart Contract — Solidity (asset CRUD)
contract AssetRegistry {
    struct Asset {
        string name;
        address owner;
        uint256 value;
        bool exists;
    }

    mapping(string => Asset) private assets;
    event AssetCreated(string indexed id, address owner);

    modifier onlyOwner(string memory id) {
        require(assets[id].owner == msg.sender, "Not owner");
        _;
    }

    function createAsset(string memory id, string memory name,
        uint256 value) external {
        require(!assets[id].exists, "Already exists");
        assets[id] = Asset(name, msg.sender, value, true);
        emit AssetCreated(id, msg.sender);
    }
}
Get the full contract with tests
4
Languages Covered
2
Test Frameworks
5
Anti-Patterns
What's inside
Fabric Chaincode in Go — PutState, GetState, DelState, rich queries with CouchDB
Fabric Chaincode in JavaScript and Java — same CRUD pattern, different APIs
Besu Solidity — mappings, events, access control modifiers, admin transfer pattern
Testing patterns — MockStub (Go) and Hardhat (TypeScript) with working examples
5 anti-patterns — non-deterministic code, missing access control, unbounded loops, and more
Deployment quick reference — Fabric lifecycle commands vs Hardhat deploy scripts
DV
By David Viejo — CTO at KFS, 6+ years in blockchain infrastructure. Creator of Bevel Operator Fabric (Hyperledger Foundation).

Get the cheat sheet

Enter your work email and we'll send you the complete cheat sheet with all 4 language examples, testing templates, and deployment commands.

Working code examples in Go, JS, Java, and Solidity
MockStub + Hardhat testing templates
Deployment command reference card
Includes Fabric 3.x CCaaS patterns and Solidity ^0.8.24 best practices.