March 2023
-
ERC721 Token Contract | Solidity Tips & Examples
The ERC721 Token contract is the original industry standard for NFTs (Non-fungible tokens). In this article we will look at a simple example and talk about some of the best practices around building ERC721 Tokens. James On YouTube Watch On YouTube: https://youtu.be/B64VBGt3tMU |Subscribe Why Use ERC721 Token ERC721 is a standard interface for NFTs on…
-
ERC20 Token Contract | Solidity Tips & Examples
ERC20 tokens have become the de facto standard for creating tokens on Ethereum and are widely used in many DeFi protocols for things like governance and utility tokens. Why Use ERC20 Token Solidity developers use ERC20 tokens because they are the industry standard for fungible tokens (where every token is equal to another one). The…
-
Merkle Tree in Solidity | Solidity Tips & Examples
Merkle Trees provide an efficient way to verify data in Solidity. This reduces the gas cost for on-chain storage when validating large data sets such as a large list of addresses. James On YouTube Watch On YouTube: https://youtu.be/NTPpyL4pJG0 |Subscribe How Do Merkle Trees Work Merkle trees are a data structure that allow efficient and secure…
-
How To Emit Events in Solidity | Solidity Tips & Examples
A Solidity Event is a way for smart contracts to communicate with the outside world by providing a mechanism for emitting messages that can be observed by external applications. It’s like a signalling message that is broadcast when a certain condition is met within the smart contract. Emitting Events In Solidity Here is a simple…
-
Bulk Send Tokens & ETH Contract | Solidity Tips & Examples
Sending payments in bulk can be a tedious and time-consuming process, especially when dealing with a large number of recipients. However, with a Solidity smart contract, bulk payments can be executed in a matter of seconds, providing a more efficient and cost-effective solution for managing bulk transfers. In this article, I will walk you through…
-
Multiple Return Values | Solidity Tips & Examples
In Solidity we can multiple return values from a function. This enables us to efficiently move data about within the application flow of a smart contract. In this example we are returning three variables enclosed within brackets. Note that the data types of these variables are defined at the top of the function in the…
-
Modifiers in Solidity | Solidity Tips & Examples
Modifiers in Solidity are a way to add a certain condition to functions within a smart contract. They allow developers to define a piece of code that can be reused across multiple functions and contracts, making your code more modular and easier to read. A modifier is defined using the modifier keyword, followed by a…
-
Struct in Solidity | Solidity Tips & Examples
A struct in Solidity is a data type that allows you to group together multiple variables of different data types into a single unit. This is useful because it gives us a convenient container to package structured data, it enables us to pack variables into memory slots more efficiently and it allows us to get…
-
Ownable Contracts | Solidity Tips & Examples
Ownable contracts in Solidity are used to implement access control for certain functions. The idea is that only the contract owner, who is typically the deployer of the contract, can execute these protected functions. To do this we will first import the OpenZeppelin library Inside our contract we can then add the onlyOwner modifier to…
-
Payable Transfers | Solidity Tips & Examples
Payable transfers are one of a number of ways to send ether from a Solidity smart contract to an external address. In this next example we create a fallback function so that any user can send this contract ether and it will get split between the different addresses. Full code at: https://github.com/jamesbachini/Solidity-Snippets/blob/main/contracts/PaymentDivider.sol Payable fails if…
-
Solidity Interface | Solidity Tips & Examples
A Solidity interface is code that provides a set of function declarations without any implementation details. Interfaces are used to interact with 3rd party contracts or external systems by defining a common set of functions that both parties agree to implement. Interfaces are used to define a contract’s external-facing functions, which is the only part…
-
OpenZeppelin Libraries | Solidity Tips & Examples
OpenZeppelin libraries are popular for building secure smart contracts on top of pre-audited code in Solidity. The framework includes a number of reusable smart contract components, such as token contracts, access control contracts, and math libraries. In this article we will explore the various Libraries available within the OpenZeppelin framework to give you a tool…
-
Arrays in Solidity | Solidity Tips & Examples
Arrays are a fundamental data structure in programming, and Solidity is no exception. In Solidity, there are several types of arrays available, including dynamic arrays, fixed-size arrays, and multi-dimensional arrays. Dynamic Arrays Dynamic arrays are the most common type of array in Solidity. These are arrays whose length can be changed during runtime. To declare…
-
Get Contract Balance | Solidity Tips & Examples
To get the contract balance in solidity there are a few different methods depending on if you want the Ether balance or an ERC20 token balance. Contract Balance Eth You can use the address type’s balance property to get the balance of any address, including the contract’s own address. The this value is used to…
-
Mapping in Solidity | Solidity Tips & Examples
This article explores how mapping in Solidity is used to for storing key->value pairs, where the keys are of a specific data type and the values can be of any data type. Mappings are declared using the mapping keyword, followed by the key data type in parentheses and the value data type after the parentheses.…
-
Variables in Solidity | Solidity Tips & Examples
Variables in Solidity can be classified into several categories based on their data types and scope. In this article we will explore all the different uses of variables in Solidity and look at some example code. Variables in Solidity Solidity variables are used to store and manipulate data in our smart contracts. They come in…
-
ERC721 vs ERC1155 | Solidity Tips & Examples
Today we will discuss the differences between ERC721 vs ERC1155 smart contracts and the use cases where each is best suited. These are the two most popular types of smart contracts used for the creation of NFTs (non-fungible tokens). James On YouTube Watch On YouTube: https://youtu.be/B64VBGt3tMU |Subscribe ERC721 Smart Contract ERC721 is the original standard…
-
ERC20 Carbon Credits | Creating A Depleting Token
Carbon credits are used to tokenise finances put towards carbon offsetting. On-chain products often have a purchase and burn mechanism where a user must first purchase the token on a DEX and then manually execute a transaction to burn the token. I had the idea to create a automatically depleting token which you just hold…
-
zkEVM | Are Zero-Knowledge Rollups The Future Of Ethereum Or A Ticking Time Bomb?
zkEVM is a zero knowledge Ethereum virtual machine, credited as being “the ultimate solution to Ethereum scaling” The Ethereum ecosystem continues to grow alongside concerns around its scalability and privacy. A new technology currently being rolled out aims to address these issues through the implementation of zero-knowledge rollups. In this article, we’ll take a closer…
-
ETHDenver | Thoughts & Takeaways From The Biggest US Blockchain Conference
This article is aimed at providing an overview summary of what was talked about at ETHDenver and some of the things I picked up while being there. Buzz Word Bingo I took the schedule and ran through how many talks there were on each of these subjects. Buzz Word No. Of Talks Zero Knowledge 18…