Category: Solidity

  • Eternal Upgradeable Pattern in Solidity

    Upgradation in smart contract is very important part, to enhance functionality or improve security. But updating a smart contract is different from tradition method. e.g. storage.sol a seperate storage contract to handle storage. and its library. Contract version 1: use the library of storage contract to access the storage contract. Backend contract version 2 Here…

  • Forced Ether Transfer

    via selfdestrcut method ether can be transferred without using payable key word. here is the example.

  • Registry Upgradeable Pattern

    Here is the first pattern to upgrade a smart contract via a middle registry contract. Which returns the new version contract. Below is the structure of Registry Upgradeable Smart Contract Pattern. Onwer.sol registry.sol this contract act as a middle man to get the address of upgraded of latest backend contract. BackendContract.sol this is the main…

  • Receive function in Solidity

    Receive function is used to get ether on contract call. It must be external with payable visibility. it only call from other contract with call method and send, transfer throw an error.

  • Fallback function in Solidity

    Fallback function execute when another contract call it with unknown function. Below is basic syntax for fallback function. There are two fallback functions, first one is simple and second is payable who can receive ethers. Three ways to call a method from another contract: Example of fallback function: when we transfer ether using fallback then…

  • Self Destruct method of Smart Contract in Solidity

    Here is the code example how can we destruct a contract. For destruction we have to set the payable address in selfdestruct method where all ethers of contract can be transferred. After destruct a contract all state variables become null, 0 or false, also we can’t update any state variable. e.g.

  • Ownerable Pattern in Solidity

    In this pattern we can define the owner of a contract, which restrict or control the protected methods, also can transfer his ownership to another.

  • Speed Dump Pattern in Solidity

    Delay in withdraw can save smart contract from malicious activity. Here is the example how you can apply a delay in smart contract.

  • Circuit Break Pattern in Solidity

    In the live contract there are many chances we find an type of error and we have to stop smart contract to handle malicious activity. here is the sample of Circuit Break Pattern.

  • State Machine Pattern in Solidity

    During developing a smart contract sometime we need to manage the different stages and execute and restrict method according to that state/stage of the smart contract.