When to use arrays vs mappings in Solidity?
Arrays are useful when you know the size of the collection in advance, and you need to be able to iterate over the elements in a specific order. Mappings are useful when you don't know the size of the collection in advance, and you need to be able to quickly lookup values. Here are a few specific scenarios where you might choose to use one over the other: 1. Use an array when you need to store a collection of items that need to be accessed by index. 2. Use a mapping when you need to asso...
Ethereum vanity addresses
Ethereum vanity address is a one-of-a-kind customized address that has portions of it chosen rather than being created at random. Why would you create a vanity address? First of all, it looks cool. The second thing it can help you with is to reinforce your brand and make you more noticeable. How to generate your own vanity address? Creating a vanity address is a straightforward trial-and-error process. When performing high-risk cryptographic operations, such as private key creation, it is imp...
Bored Ape Yacht Club: Smart Contract Breakdown
Bored Ape Yacht Club (BAYC) is a popular NFT collection created by Yuga Labs. In this post, we’ll go over BAYC smart contract code. The source code is available on EtherScan.ERC721BAYC is implemented as an ERC721 token, a standard that defines a set of functions that a smart contract must implement in order to be considered a compliant ERC721 token. These functions include the ability to transfer tokens, approve other addresses to manage your tokens, and check token ownership.ERC721 interface...
Co-founder & CTO of Blank. Building software and helping companies enter web3.
When to use arrays vs mappings in Solidity?
Arrays are useful when you know the size of the collection in advance, and you need to be able to iterate over the elements in a specific order. Mappings are useful when you don't know the size of the collection in advance, and you need to be able to quickly lookup values. Here are a few specific scenarios where you might choose to use one over the other: 1. Use an array when you need to store a collection of items that need to be accessed by index. 2. Use a mapping when you need to asso...
Ethereum vanity addresses
Ethereum vanity address is a one-of-a-kind customized address that has portions of it chosen rather than being created at random. Why would you create a vanity address? First of all, it looks cool. The second thing it can help you with is to reinforce your brand and make you more noticeable. How to generate your own vanity address? Creating a vanity address is a straightforward trial-and-error process. When performing high-risk cryptographic operations, such as private key creation, it is imp...
Bored Ape Yacht Club: Smart Contract Breakdown
Bored Ape Yacht Club (BAYC) is a popular NFT collection created by Yuga Labs. In this post, we’ll go over BAYC smart contract code. The source code is available on EtherScan.ERC721BAYC is implemented as an ERC721 token, a standard that defines a set of functions that a smart contract must implement in order to be considered a compliant ERC721 token. These functions include the ability to transfer tokens, approve other addresses to manage your tokens, and check token ownership.ERC721 interface...
Share Dialog
Share Dialog
Co-founder & CTO of Blank. Building software and helping companies enter web3.

Subscribe to 0xMarko

Subscribe to 0xMarko
<100 subscribers
<100 subscribers
I've noticed that smart contracts can be confusing, even for developers diving into web3.
Let's go back to the basics and explore how Ethereum smart contracts are created, deployed, and executed.
Smart contracts are just programs on the Ethereum blockchain. It's a collection of code (its functions) and data (its state) that resides at a specific address on the Ethereum blockchain.
Data = how many NFTs I have
Code = how to transfer NFT from A to B
To create a smart contract, developers usually write code in a programming language called Solidity. It's a high-level language designed specifically for Ethereum, inspired by C++, Python, and JavaScript.
You'll also see terms like Hardhat and Foundry when talking about smart contracts development. Those are special development environments that simplify the process of building, deploying, and testing smart contracts.
In Solidity, when we compile the code, we get bytecode and ABI.
Bytecode is the machine-readable format that the Ethereum Virtual Machine (EVM) can understand and execute. Bytecode consists of concise numeric codes, constants, and various data elements.
ABIs are application binary interfaces. They define the variables and methods that are available in a smart contract. Thanks to ABI, we know how to interact with that smart contract.
ABIs are represented as JSON and can look like this:

After the contract is compiled, it's time for deployment. Deployment means sending the contract to the Ethereum blockchain. It's done by creating a special transaction with the contract bytecode as data and no recipient address.
The contract is officially deployed when the deployment transaction is included in a block. The contract gets its own unique address on the blockchain, derived from the sender's address and nonce (number of transactions sent from a given address).
Fun facts:
You can calculate a smart contract address before deployment.
You can deploy a smart contract to multiple EVM chains to the same address.
Here is a Clone X contract deployment transaction. Notice the absence of a "To" address – this indicates that a new contract is being created (RTFKT: CloneX Token). The Input Data contains a lengthy string, which is the source code of the contract.

Now that the contract is deployed, anyone can interact with it through its functions.
There are two types of functions:
write functions that require transaction and cost gas
read functions that are free and don't require transaction
Write functions modify the contract state. These changes need to be propagated across the network, verified, and stored by validators in a new block. Validators require compensation for their work, which is why gas fees are associated with write functions.
Read functions don't require any changes to the blockchain state; they only access the current data. Since they don't involve modifying the blockchain, they can be executed locally on any node without needing a transaction or consensus. This makes them free of cost.
Validators pick up the transaction, execute the function within the EVM, and include the transaction in a block. The results of the function execution are recorded in the blockchain as part of the transaction receipt.
I hope this info helps demystify Ethereum smart contracts a bit. As smart contracts become more vital in shaping our digital future, it's important to understand how they work. Keep exploring and stay informed!
I've noticed that smart contracts can be confusing, even for developers diving into web3.
Let's go back to the basics and explore how Ethereum smart contracts are created, deployed, and executed.
Smart contracts are just programs on the Ethereum blockchain. It's a collection of code (its functions) and data (its state) that resides at a specific address on the Ethereum blockchain.
Data = how many NFTs I have
Code = how to transfer NFT from A to B
To create a smart contract, developers usually write code in a programming language called Solidity. It's a high-level language designed specifically for Ethereum, inspired by C++, Python, and JavaScript.
You'll also see terms like Hardhat and Foundry when talking about smart contracts development. Those are special development environments that simplify the process of building, deploying, and testing smart contracts.
In Solidity, when we compile the code, we get bytecode and ABI.
Bytecode is the machine-readable format that the Ethereum Virtual Machine (EVM) can understand and execute. Bytecode consists of concise numeric codes, constants, and various data elements.
ABIs are application binary interfaces. They define the variables and methods that are available in a smart contract. Thanks to ABI, we know how to interact with that smart contract.
ABIs are represented as JSON and can look like this:

After the contract is compiled, it's time for deployment. Deployment means sending the contract to the Ethereum blockchain. It's done by creating a special transaction with the contract bytecode as data and no recipient address.
The contract is officially deployed when the deployment transaction is included in a block. The contract gets its own unique address on the blockchain, derived from the sender's address and nonce (number of transactions sent from a given address).
Fun facts:
You can calculate a smart contract address before deployment.
You can deploy a smart contract to multiple EVM chains to the same address.
Here is a Clone X contract deployment transaction. Notice the absence of a "To" address – this indicates that a new contract is being created (RTFKT: CloneX Token). The Input Data contains a lengthy string, which is the source code of the contract.

Now that the contract is deployed, anyone can interact with it through its functions.
There are two types of functions:
write functions that require transaction and cost gas
read functions that are free and don't require transaction
Write functions modify the contract state. These changes need to be propagated across the network, verified, and stored by validators in a new block. Validators require compensation for their work, which is why gas fees are associated with write functions.
Read functions don't require any changes to the blockchain state; they only access the current data. Since they don't involve modifying the blockchain, they can be executed locally on any node without needing a transaction or consensus. This makes them free of cost.
Validators pick up the transaction, execute the function within the EVM, and include the transaction in a block. The results of the function execution are recorded in the blockchain as part of the transaction receipt.
I hope this info helps demystify Ethereum smart contracts a bit. As smart contracts become more vital in shaping our digital future, it's important to understand how they work. Keep exploring and stay informed!
No activity yet