Code
-
Encrypting Private Keys in .env
It has become very normalised to store Ethereum private keys in plain text within .env files. While this is convenient, it’s a disaster waiting to happen when working in production with wallets that contain real funds. Today, I’ll show you a better way to manage your hot wallet keys using AES encryption. Full code for…
-
Balancer v3 Hooks
For the Balancer v3 Hookathon (yep it’s a hackathon to create DeX hooks) I had the idea to try and create a fair launch memecoin platform. It’s the kind of thing that could bring utility to the ecosystem as we’ve seen recently with the wave of memecoin trading on Solana. The target is to create…
-
Creating WASM Files Using Rust and Running Them in the Browser
In this tutorial we will be writing some code in Rust, compiling to web assembly (WASM) and then running that code in a browser. This enables high performance applications to be run within a web dev setting. In this tutorial I’ll be using windows subsystem for Linux. Let’s first install Rust and wasm-pack (more instructions…
-
Understanding ABI Encoding: A Guide to abi.encodeCall and encodeWithSelector
What Is ABI Encoding Application Binary Interface (ABI) encoding is a crucial concept in Ethereum smart contract development. It serves as a standardised method for encoding function calls and data, enabling seamless communication between different components of the Ethereum ecosystem. ABI encoding ensures that data is consistently formatted and interpreted across various platforms and programming…
-
Enums In Solidity
Enums are one of the most useful and underused data types in Solidity. I think because they aren’t widely used in Javascript and web dev, they often get overlooked in contract development. In this article I’ll make my case for why enums deserve a place in your tool kit and smart contracts. Enums in Solidity…
-
WebAuthn PassKey Smart Wallets
In this article we will take a glimpse into the future of account abstraction where web3 can offer walletless, passwordless authentication to web applications. I’ll be connecting a Stellar Soroban smart contract to a web3 frontend and verifying signatures from biometrics on your phone. Welcome to the future. The full source code used in this…
-
React Hooks Tutorial | The 7 Most Important React Hooks
React Hooks provide a way to manage state, side effects, references and more in functional components. In this tutorial, we’ll look at the seven most commonly used React hooks When You Would Use These React Hooks useStateImagine you have a piece of data in your component that might change, like a number for a counter…
-
Building Rust Smart Contracts On Stellar Soroban
Soroban is the smart contract platform that allows developers to write and deploy smart contracts on the Stellar network. This tutorial will guide you through the process of building a simple smart contract using Rust and deploying it to Soroban. I recently took on the role of Developer in Residence with Stellar and this is…
-
Pump.fun Clone In Solidity
Pump.fun is a token factory that lets users create and trade memecoins on Solana with dynamic pricing along a bonding curve. In this article I’ll show how I went about converting this concept to Solidity and deploying it on Ethereum. Full code for this is open source at: https://github.com/jamesbachini/Pump.sol Token Factory Contract At the core…
-
Creating Your Own Oracle Solidity & NodeJS
In this tutorial I’m going to go through the steps to setting up your own oracle service to bring data on-chain. We are going to be deploying a simple smart contract, then setting up a NodeJS client to fetch the price of Bitcoin, then uploading this to the contract. Full code for this is open…
-
Format JSON Tool
A simple tool to lint and format JSON because I was fed up of using the ones covered in ads. Format JSON The Javascript code that makes this work is quite simple: It can be used to format outputs prior to displaying the results of API queries or any other JSON found wild around the…
-
How To Calculate Gas Costs For Solidity Contracts
Deploying Solidity smart contracts can be expensive because the code needs to be stored on the shared storage of a decentralized peer to peer blockchain network. The dollar cost of deploying Solidity smart contracts is dependent on a number of variables: I’ve previously provided code to analyze the bytecode size of contracts, you can also…
-
NFT Token Vault Solidity
This was inspired by the CryptoKitties WG0 token vault which accepts gen zero CryptoKitty deposits and mints 1 ERC20 token for each. Users can then buy tokens on exchange and claim NFT’s from the vault. The code is open source and available at: https://github.com/jamesbachini/NFTvault How The NFTvault Contract Works When you deposit your NFTs into…
-
Creating an UpOnly ERC20 Token
In this tutorial we are going to create a ponzi game in the form of an ERC20 token that has an internal marketplace function. The idea is to increase the price over time so that early buyers get to dump on late buyers at a higher price. The last buyer will have no liquidity to…
-
Solidity Encrypted Messaging dApp
This morning Pavel Durov, founder of Telegram, was arrested at a French airport for refusing to provide backdoor access to the messaging application. This tutorial will demonstrate how to use Elliptic Curve Diffie Hellman (ECDH) cryptography to establish a shared secret and encrypted messaging across a insecure communication channel, in this case a public blockchain.…
-
Script To Analyze Bytecode Size Of Smart Contracts
I was having trouble with the hardhat bytecode plugin so I wrote a little nodejs script which will print off the size of my compiled Solidity contracts. You’ll need nodejs installed and can then run it like this. You should get an ouput like this: Here’s the code to save to analyze_bytecode.js file in the…
-
Solidity Virtual Pet
Let’s create a virtual pet in Solidity and deploy it to the blockchain. Full frontend and contract code for this tutorial can be found here: https://github.com/jamesbachini/Solidity-Virtual-Pet Demo here: https://jamesbachini.com/misc/SolidityPet/index.html Smart Contract Our pet is going to have two attributes for hunger and happiness. Hunger should increase over time and happiness should have a mechanism where…
-
How To Scrape Twitter/X Without API Access
Scraping Twitter/X without direct API access can be accomplished by leveraging third-party services like RapidAPI, which provides a streamlined way to interact with Twitter data. In this tutorial, we’ll walk through the process of using RapidAPI to scrape tweets from a specified user. I’m going to provide code snippets in Python and NodeJS for this…
-
Calculating Bitcoin Fair Value With Rust
In this tutorial, we will create a Rust script that: Instructions Rust Code The code is open source and available on Github: https://github.com/jamesbachini/Bitcoin-Fair-Value We’ll start with the async fetch_klines function to fetch Bitcoin price data from the Binance API. The Binance API provides various endpoints for accessing market data, and we’ll use the /api/v3/klines endpoint…
-
Can ChatGPT & Keras Predict The Price Of Bitcoin
I get asked a lot if ChatGPT can be used for trading and I normally say “no, it’s a language model which isn’t designed to find market patterns in numerical price data”. ChatGPT works more like predictive text in a search engine or on your phone but what it is good at is writing code…
-
Calculating CAGR in Python & JavaScript
The Compound Annual Growth Rate (CAGR) is a useful measure for assessing the mean annual growth rate of an investment or business metric over a specified period longer than one year. Unlike other growth metrics, CAGR smooths out the volatility, providing a clearer picture of how investments grow over time. In this guide, I’ll show…
-
How To Check Token Balances Using Python
To check a wallet token balance on the Ethereum blockchain using Python you will need the following: Once we have our API key ready and Python installed we can install web3.py using the following command Now let’s create a file called balance.py and add the following code. Note the code is also available in the…
-
DeFi Analysis With Rust
In this tutorial I’m going to provide some code and show you how to monitor the number of depositors to Eigenlayer over the last 24 hours. We will be using Rust with the Tokio and Ethers libraries along with the Infura API which you can get a free key from here. The first thing we…
-
How To Lookup An ENS Name In Python
To check a wallet token balance on the Ethereum blockchain using Python you will need the following: Once we have our API key ready and Python installed we can install web3.py using the following command Now let’s create a file called enslookup.py and add the following code. Enter your Infura API key on line 5.…
-
Building A Portfolio Tracker In Python
In this tutorial we will be building a digital asset portfolio tracking tool using python and the Coinbase API. You’ll need to install python and the following library to make requests. The code for this is open source on Github at: https://github.com/jamesbachini/Python-Portfolio-Tracker Put this in a file called portfolio.py or fork the repo above. Then…
-
Creating A Solidity Escrow Smart Contract
In this tutorial, we will create an Escrow contract using Solidity and deploy it to an Ethereum testnet. An Escrow contract is a financial agreement where a third party (the arbitrator) holds and regulates payment of the funds required for two parties involved in a given transaction. It helps make transactions more secure as it…
-
How To Create ERC404 Tokens Solidity Tutorial
An ERC404 token is a digital asset that combines the characteristics of ERC20 fungible tokens and ERC721 non-fungible tokens (aka NFT’s) to enable fractional ownership of an NFT. In essence, ERC404 tokens represent divisible parts of an NFT, allowing multiple individuals to own shares of a single NFT. This approach is designed to enhance the…
-
Adversarial Simulation Testing For Smart Contract Developers
I recently read Gene Kranz’s first hand account of the Gemini and Apollo Nasa missions. He talks about the rigorous simulation testing that flight directors had to partake in prior to a mission. Simulation testing plays a crucial role in ensuring the preparedness of astronauts and flight controllers for spaceflight. This process is managed by…
-
Javascript Smart Contracts
As an experiment I converted this Vyper token contract to a Javascript/Typescript syntax to see if we could make it easier for web developers to get up to speed with smart contract development. Solidity is the most popular smart contract language and it is already based losely on Javascript but there are plenty of syntax…
-
Vyper Tutorial | Learn Vyper In 24 Hours
Vyper is a pythonesque smart contract language that can be compiled and deployed on Ethereum and other EVM blockchains. 90%+ of blockchain devs use Solidity but there are some big projects such as Curve using Vyper and it’s growing in popularity and tooling compatibility. The best way to get started with Vyper is to head…
-
Using Vyper With Remix
You can now use Vyper (a smart contract programming language similar to python) with remix to build and deploy contracts on Ethereum and other EVM blockchains. The first step is installing the Vyper plugin at https://remix.ethereum.org/ where you’ll find a list of plugins using the icon in the bottom left. You’ll then get an extra…
-
Sell Me This Pen.sol
What happens when you ask a blockchain developer to sell you a pen? Etch your words permanently on the Ethereum blockchain where they will outlive you & create an everlasting record of your thoughts, contemplations & predictions. This is your chance to leave an eternal mark and express your presence in the digital age while…
-
How To Deploy A Website Or dApp To IPFS | Fleek Tutorial
Gm, in this tutorial we are going to be deploying a website to IPFS to create a decentralized frontend. To do this I’ll be using Fleek which has a free tier and which suits our needs. James On YouTube Watch On YouTube: https://youtu.be/https://youtu.be/DmpXbmjnpec |Subscribe We will start by getting our site on Github. We can…
-
Etherspot Account Abstraction Tutorial
I find it surprising and rare when using new technology and it just works and is intuitive. Getting up to speed with Etherspot and account abstraction is one of those rare occasions. In this tutorial I’ll show you how I created a little demo to create a smart wallet, fund it and then send batched…
-
TradingView Pine Script Examples | Master Pine Script With 6 Real World Examples
TradingView’s Pine Script coding language has emerged as the leading tool for traders looking to craft custom indicators and strategies with accuracy and ease. In this Pine Script tutorial I’ll provide a practical gateway into the intricacies of this coding language, tailored with useful examples to get you started. Whether you’re a novice coder or…
-
Solidity Proxy Contract Tutorial With Example Code
This Solidity proxy contract tutorial delves into the concept of upgradeable proxy contracts in Solidity, specifically utilizing OpenZeppelin’s proxy contract template. We’ll start with an understanding of how these contracts work, the compromise of immutable decentralization vs upgradeability and then dive into practical code examples. Proxy Contract Video Tutorial In this video I provide an…
-
Web3 Session Keys
We are going on a journey to seamlessly integrate session keys into a web3 dApp, striking a balance between autonomy and ease of use that your users are yearning for. The goal is to enable users to authenticate with a digital wallet and store a session key on their device. This session key will provide…
-
Ethers-rs Tutorial | The Rust Web3 Library
In this tutorial we will be setting up a Rust script to connect to a smart contract on a blockchain network to display on-chain data using the ethers-rs library. James On YouTube Watch On YouTube: https://youtu.be/FA7WFGtyri8 |Subscribe Let’s start by setting up a new Rust project (you’ll need rust installed on your device and I’ll…
-
ChatGPT Plus vs Free | Is The Paid Version Of ChatGPT Worth It?
ChatGPT Plus vs Free [Video] James On YouTube Watch On YouTube: https://youtu.be/U3xXd3vV4iU |Subscribe Why Upgrade To ChatGPT Plus? ChatGPT Plus is the paid version of ChatGPT, it currently costs $20/month + VAT and there are 3 main reasons why the average user would want to upgrade to the premium version: On top of this paid…
-
WAGMI Tutorial | The Web3 React Framework
WAGMI is a set of Typescript React hooks for web3 which enables developers to connect to smart contracts on blockchain networks. In this tutorial we will look at how to install and setup a boilerplate in WAGMI and then build a simple read query. WAGMI in 3 Mins [Video] James On YouTube Watch On YouTube:…
-
How I Track Developer Activity For Crypto Projects
In this article I’m going to share how to track developer activity for crypto projects for fundamental analysis. James On YouTube Watch On YouTube: https://youtu.be/DTI7ELSA6CA |Subscribe Understanding the Crypto Development Ecosystem Cryptocurrencies like Bitcoin and Ethereum as well as the majority of blockchain projects are fundamentally software. They are applications that run on a decentralized…
-
How I Built A Smart Money List On Twitter
X formerly known as Twitter includes two features which allows us to create a list of accounts from people that frontrun narratives and successful trades. tl;dr if you just want to see the final list it is here: https://twitter.com/i/lists/1712044491618545903 James On YouTube Watch On YouTube: https://youtu.be/4qYraarbsYs |Subscribe Step 1. Collecting Project Data My main focus…
-
OpenZeppelin 5 Solidity Common Errors
OpenZeppelin have just released version 5 of their Solidity smart contract libraries and there are some breaking changes that are going to cause errors. The two main ones are the Ownable.sol import which allows devs to create onlyOwner functions and the token hooks on ERC20, ERC721 & ERC1155 contracts. Ownable Constructor If you are getting…
-
Hardhat Solidity Tutorial
Hardhat is an extensive framework for developing, testing and deploying solidity smart contracts. In this Hardhat Solidity tutorial you will learn how to set it up, how to create hardhat unit test tricks, working with hardhat scripts and finally some Hardhat tips and tricks for Solidity developers. Hardhat Easy Setup Hardhat is built on NodeJS…
-
NEAR BOS | Blockchain Operating System
Near BOS is a complete framework designed for creating, testing, deploying and distributing decentralized application frontends. Developers can create Javascript based dApps with the frontend code stored and distributed from a blockchain. It is blockchain agnostic so you can store data on Near and EVM chains. BOS is a collection of components, blockchains & gateways.…
-
Hardhat vs Foundry
I started developing solidity with Truffle, then moved to Hardhat, then moved to Foundry, then moved back to Hardhat before eventually settling using both on a regular basis. In this article I’ll talk about the benefits and disadvantages of Hardhat and Foundry so you can make an informed decision about which framework is better for…
-
Calculating The Intrinsic Value Of Bitcoin & Ethereum
Calculating the intrinsic value of Bitcoin, Ethereum and other digital assets is challenging due to its intangible nature. In this analysis I’m going to discuss common methods of calculating intrinsic value and then create a model using a combination of the methods. tl;dr based on the models described below: Methods Of Calculating Intrinsic Value Store…
-
Solidity Tutorial | Gas Paying NFT
The challenge is to create a NFT contract that charges 1 ETH to mint but then stores the entire amount as collateral in a liquid staking token. As staking rewards come in they get distributed to the holders of the NFTs. At any time a user can burn the NFT to reclaim the 1 ETH.…
-
Web3 PWA Boilerplate | How To Create Next Generation dApps
One of Web3’s biggest issues is getting around the centralization of app stores and their stringent terms on the commission requirements for digital asset payments and transfers. Progressive Web Apps (PWAs) in my opinion are the best solution as it allows you to install dApps directly on to a mobile device without using the app…
-
Chainlink CCIP | Cross-Chain Interoperability Protocol
From all the announcements at ETHcc, the release of Chainlink CCIP as a direct competitor to LayerZero for cross-chain communications and bridging technology, is perhaps the most interesting. The inherent security risks associated with bridging technology means that Chainlink are in a good position to leverage their brand and security record to gain traction in…
-
Using Ethereum To Offset Bitcoin’s Carbon Footprint
Never have I sounded more like an Ethereum maxi, but there is a point beyond the provocative title. In this post I’m going to explore the potential for investors to use carbon credit tokens on Ethereum to offset the electrical consumption of BTC mining on their Bitcoin holdings. This novel idea provides the opportunity to…
-
How To Shuffle A Deck Of Cards In Solidity
In this post I explore how to simulate the shuffling of a deck of cards, addressing the challenges of randomness and predictability in a solidity smart contract environment where every input and output is part of the public record. Whether you’re looking to create an on-chain poker game, a collectible card game, or you’re simply…
-
Card Payments For Crypto With Wert
One of the challenges cryptocurrency projects face is the seamless integration of traditional payment systems, such as credit/debit card payments, into their crypto based ecosystems. The issue derives from the potential for fraud because card payments can be reversed long after the transaction has taken place, while crypto transactions are immutable. This is a write…
-
Automate Solidity With MEV
There are no cron jobs in Solidity or native to the Ethereum blockchain. To automate Solidity code we can either use an external service/oracle or we can incentivise MEV searchers to complete tasks efficiently on our behalf. This type of Solidity automation is very common and used widely across liquidation systems which require reliable, fast,…
-
Solana SoLang Tutorial | How To Deploy Solidity On Solana
In this SoLang tutorial I’ll show you how to deploy Solidity code on Solana. We will start by setting up a dev environment before looking at some of the nuances in writing SoLang contracts. I’ll end on a few security considerations and a comparison to developing on Solana with SoLang vs Rust. Setting Up A…
-
XRP Legal Case | What It Means For Developers
In this article I’m going to be breaking down the document filed by judge Torres yesterday and consider what it means to developers working in the blockchain and web3 space. Highlights From The Ruling The full document is available here:https://www.nysd.uscourts.gov/sites/default/files/2023-07/SEC%20vs%20Ripple%207-13-23.pdf I’ve picked out some highlights Programmatic SalesHaving considered the economic reality of the Programmatic Sales,…
-
Uniswap v4 Hooks
Hooks in Uniswap v4 are external contracts that execute specific actions at certain points during the execution of a liquidity pool. These hooks provide flexibility and customization options for developers to create additional features for liquidity pools. Uniswap v4 hooks can be used to: A 3rd party developer can write a solidity hook contract with…
-
Solidity Error Codes | Not Always What They Seem
I get a lot of comments from Solidity tutorial videos and in Github issues asking how to resolve common solidity error codes. In this article I’ll go through some of the most frequent solidity issues, what they mean and how to resolve them. UNPREDICTABLE_GAS_LIMIT This is the most common and confusing error in Solidity The…
-
Gnosis Safe | The Most Secure Multisig Wallet For Your Crypto
Gnosis Safe multisig wallets are used by institutions and individuals to hold some of the largest quantities of funds on the Ethereum network. The free to use wallet includes multisignature functionality for enhanced security and control over digital assets. It is developed by Gnosis, a blockchain technology company based out of Switzerland and Germany, known…
-
How Wrapped Tokens Like wETH & wBTC Work
In this article we will look at how different wrapped tokens work and where the underlying collateral is stored. What Are Wrapped Tokens? Wrapped tokens are generally ERC20 tokens that represents another underlying asset, typically a cryptocurrency or real world asset. The purpose of wrapping a token is to enable its use within the DeFi…
-
3 Tips For Gas Efficient Solidity Smart Contracts
Here are 3 tips which could be considered the low hanging fruit of gas efficient solidity smart contracts. James On YouTube Watch On YouTube: https://youtu.be/xfNHzqkMWEQ |Subscribe Use Correct Modifiers & Declarations This is the simplest way to get some small wins with gas optimisation. Go through your contract and define anything that shouldn’t change as…
-
Introduction to Flash Loans | Unleashing Capital On Demand
In this tutorial on flash loans we will be creating a Solidity smart contract which takes a flash loan from Uniswap v3. This allows you to borrow huge amounts of capital with the catch that you have to pay it back in the same block or the whole transaction is reverted. James On YouTube Watch…
-
Uniswap Market Maker Bot | Managing Token Liquidity On Uniswap
In this tutorial I am going to go through how I built a market maker bot to manage liquidity on Uniswap v3 for a token pair. The idea is to create a automated trading bot which buys tokens when price falls below a base line value and sells tokens when price is above the base…
-
Ethers vs VIEM | Which Web3 Frontend Library?
Ether.js took over from Web3.js as the number one library for connecting up our dApps to smart contracts running on EVM blockchains. Recently Ethers v6 was released and VIEM is disrupting the space by offering a lightweight Ethereum client library from the authors of WAGMI react hooks. I have always been a big fan of…
-
How To Create A BRC20 Bitcoin Token
In this tutorial we will create our own BRC20 token on the Bitcoin network. James On YouTube Watch On YouTube: https://youtu.be/6eTN2fVd4Pw |Subscribe What are BRC20 Tokens? BRC20 tokens are created using the Bitcoin Ordinals protocol. The Ordinals protocol is a set of rules that govern how inscriptions are created, transferred and managed. Bitcoin and the…
-
Bitcoin Ordinals
Bitcoin ordinals are a means of creating NFTs by attaching data such as images, videos, and more to an individual satoshi on the base Bitcoin blockchain. They use an arbitrary but logical ordering system called ordinal theory to give each individual Bitcoin satoshi a unique non-fungible reference. What Are Bitcoin Ordinals? Bitcoin ordinals, also known…
-
Solidity vs Vyper
Solidity and Vyper are the two most popular programming languages for blockchain developers on Ethereum. Both of these languages have their own strengths and weaknesses which we will go through to help developers decide which is best suited for their project. Solidity Solidity is the most widely used programming language for developing smart contracts on…
-
Sign In With Ethereum Tutorial
To sign in with Ethereum using Metamask we will be using the ERC4361 specification that allows Ethereum accounts to authenticate with off-chain services using a standard message format. This technology offer users a self-custodial alternative to centralized identity providers that generally use email:password credentials. In Web3 applications we can improve user experiences and establish a…
-
Solidity Callback | Solidity Tips & Examples
A callback function in Solidity allows us to pass a function reference from one contract to another and have it execute as part of an atomic transaction. James On YouTube Watch On YouTube: https://youtu.be/pjm0eOelPXc |Subscribe Let’s first take a look at an example from the Solidity Snippets Github repo. Full code at: https://github.com/jamesbachini/Solidity-Snippets/blob/main/contracts/Callback.sol This code…
-
Strings in Solidity | Solidity Tips & Examples
A string in Solidity is a data type used to store text. Working with strings in Solidity can be challenging due to the limitations and efficiency required by the Ethereum virtual machine. This article aims to provide a comprehensive guide on how to use strings in Solidity, covering their properties, limitations, and best practices for…
-
Timestamp in Solidity | Solidity Tips & Examples
A timestamp is a numerical value that represents a specific moment in time. It’s often used to track when a certain event occurred or when a piece of data was created or modified. The most common way to represent a timestamp is by using the number of seconds that have elapsed since a specific moment…
-
encodeCall in Solidity | Solidity Tips & Examples
From Solidity version 0.8.11 we can use an interface to define a function to pass to encodeCall parameters. encodeCall is a function that allows you to encode a function call with its parameters into a single byte array. This byte array can then be used to make a low-level call to another contract’s function. Here…
-
Custom Error Handling in Solidity | Solidity Tips & Examples
Custom error handling enables Solidity developers to efficiently handle reverts and failed transactions including logging parameters. Let’s first take a look at an example from the Solidity Snippets Github repo: Note that the Solidity compiler version must be greater than 0.8.4 to use custom errors. Customer errors are supported by Etherscan and most other block…
-
Solidity Libraries | Solidity Tips & Examples
A solidity library is a reusable contract that contains functions that can be called by other contracts. When you import a Solidity library into your contract, you can use the functions provided by the library. How To Import Solidity Libraries In your smart contract, you can import the library by using the import keyword followed…
-
Random Numbers in Solidity | Solidity Tips & Examples
Generating a random number in Solidity is not as straightforward as in some other programming languages, because the Ethereum blockchain is deterministic, meaning that multiple execution clients or nodes must come to the same conclusion about the state of the blockchain. For many use cases using the new prevrandao global variable provides “good enough” randomness…
-
Conditional Statements & Loops in Solidity | Solidity Tips & Examples
Conditional statements & loops in Solidity are fairly intuitive and follow the conventions of other languages such as Javascript. In this article we will go through some examples of each before looking at the relational operators we can use within these statements. if statement The “if” statement is used to execute a block of code…
-
Natspec in Solidity | Solidity Tips & Examples
Natspec comments are important for Solidity developers to understand because sooner or later you will come across a code base that requires you work with them. Proponents will say Natspec makes the code more readable and understandable. While I personally disagree with this and prefer to separate code and documentation, the format is popular and…
-
How The Twitter Algorithm Works
On the 31st March 2023 Twitter open-sourced large sections of it’s algorithm which ranks content. This provided refreshing insights into how large scale social media applications rank content. In this article I’m going to look at how the algorithm works and how content creators can use this new information to gain more reach and influence.…
-
ERC1155 Token Contract | Solidity Tips & Examples
ERC1155 offers a more flexible and efficient way of managing fungible and non-fungible tokens, making it an attractive option for developers who want to create complex digital assets with multiple use cases. In this blog post, we’ll dive into the details of ERC1155 and explore why it’s becoming a preferred choice for Solidity developers looking…
-
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…
-
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…
-
Advanced ChatGPT Prompt Engineering
By now you have probably experimented with ChatGPT and realised the huge potential this “calculator for words” has. In this article I share the results of my research on how to make the most of this powerful tool. Whether you’re using ChatGPT as a personal assistant or in a professional setting, you’ll find some valuable…
-
Remixd Tutorial | How To Take The Solidity IDE To The Next Level
I’ve gone full circle from Remix > Hardhat > Foundry > Remix I find that I enjoy coding most when I’m experimenting with ideas and proof of concepts within the Remix IDE at https://remix.ethereum.org However for more serious projects I inevitably find myself moving out of creative mode and into testing mode in either Hardhat…
-
LayerZero Example | How To Send Cross-Chain Messages In Solidity
In this article we are going to look at how to send messages or data from one chain to another. In this LayerZero example we will be sending a string from Ethereum’s Goerli Testnet to Optimisms Layer 2 Goerli Testnet. Cross-Chain Tutorial Video James On YouTube Watch On YouTube: https://youtu.be/rKVhQHmljXM |Subscribe How LayerZero Works LayerZero…