Skip to content

LazyChain Contracts is a library for secure smart contract developed to use in the platform.

Notifications You must be signed in to change notification settings

Lazychain/solidity-contracts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LazyChain Smart Contracts

Documentation

Check docs project.

Installation

Install bun

curl -fsSL https://bun.sh/install | bash

Install foundry

curl -L https://foundry.paradigm.xyz | bash
# Follow on-screen command

Install all the packages

bun i

Build contracts

forge build
# Or
npm run build
Success message
> @lazychain/[email protected] build
> forge build --extra-output-files bin --extra-output-files abi

[⠊] Compiling...
[⠢] Compiling 12 files with Solc 0.8.24
[⠆] Solc 0.8.24 finished in 118.77ms
Compiler run successful!

Tools

Foundry Testing

stateless fuzzing

Test should have to be design to receive (inject) the variable we want to test (Inversion of control). On foundry, we can do this be configuring the foundry.toml add [fuzz] section.

State full fuzzing

On foundry: - import StdInvariant.sol. - Inherit on the test contract is StdInvariant, Test. - On Setup() set the entrypoint targetContract(address(<contract under test>)).

Coverage guide fuzzing

on Echidna or Medusa.

Example

// src/contracts/MyContract.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

contract MyContract {

    struct UserNameSpace {
        address userAddress;
        string nickName;
        uint256 draws_count;
        uint256 win_count;
    }

    function updateUserNameSpace(UserNameSpace calldata newNamespace) public {
        // ... implementation logic
    }
}

Foundry

// test/MyContractTest.t.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import "forge-std/Test.sol";
import "../src/contracts/MyContract.sol";

contract MyContractTest is Test {
    MyContract myContract;

    // Needed so the test contract itself can receive ether
    // when withdrawing
    receive() external payable {}

    function setUp() public {
        myContract = new MyContract();
    }

    function testUpdateUserNameSpaceFuzz(address userAddress, string memory nickName, uint256 drawsCount, uint256 winCount) public {
        UserNameSpace memory namespace = UserNameSpace(userAddress, nickName, drawsCount, winCount);
        myContract.updateUserNameSpace(namespace);

        // Add assertions here to check the state of the contract after the update
        // ...
    }
}

forge test

Echidna

TODO

hardhat Test

TODO

Gas tracking

-gas-tracking

forge install transmissions11/solmate
forge remappings

About

LazyChain Contracts is a library for secure smart contract developed to use in the platform.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •