Skip to main content
Category

Ethereum

Code Like a Pro: The Quick Path to Smart Contract Mastery

Code like a pro

This article was written by Boro and Uri, Mighty Block blockchain developers, You will find in it the path to becoming a Smart Contract Developer!

Stepping into the digital realm’s dynamic frontier, where innovation intertwines with decentralization, is the path of a smart contract developer. In a world shifting from Web 2.0 to Web 3.0, our role has gained unprecedented prominence.

Imagine writing code that represents unalterable agreements and cutting out intermediaries – that’s the magic of smart contracts. This article is your gateway to understanding what it takes to become a master of this blockchain-powered craft. From unraveling the intricacies of different programming languages to illuminating the deployment process on diverse blockchain platforms, we’ll embark on a journey that unveils the profound evolution from lines of code to immutable digital contracts.

What is a smart contract?

At its core, a smart contract is a decentralized digital agreement that runs on a blockchain. Imagine a traditional contract that outlines the terms and conditions of a transaction or agreement. And now envision this contract automated, enforced, and executed without needing intermediaries. This is where smart contracts shine.

Structurally, code composes a smart contract and defines the rules, logic, and conditions of an agreement. Think of it as executing a virtual ‘if-then’ statement: if certain pre-defined conditions meet, then the contract executes a specific set of actions. This structure ensures the transactions to be tamper-proof, transparent, and irreversible once executed on the blockchain.

Why web3

In the evolution of the internet, we’ve moved from the static websites of Web 1.0 to the interactive platforms of Web 2.0. The transition to Web 2.0 brought us social media, online collaboration, and user-generated content, all centralized on platforms owned by big tech companies.

However, the model came with drawbacks. User data privacy concerns and the centralized control of information became apparent as platforms monetized user data and exercised content moderation power.

This sets the stage for Web 3.0, a decentralized paradigm shift. Web 3.0 leverages blockchain technology to distribute control, data ownership, and transactions across a network of participants. This means that users own more of their data and identities, and execute transactions in a transparent and secure manner without intermediaries.

As data breaches, content censorship, and privacy issues continue to plague the digital landscape, the move towards Web 3.0 gains momentum. Its emphasis on user empowerment, privacy, and open protocols is driving innovation. With the potential to redefine how we interact online, from social networking to financial transactions.

Main smart contract structure

Let’s say we want to create an ERC20, the MightyBlockCoin that goes by the ticker MBC, our contract should keep track of MBC wallet balances, allow to transfer between wallets, amongst other functionalities. This is what the structure of such a contract would look like:

  • Constructor: This piece of code executes before the deployment finishes and typically sets some initial data on the storage of the contract. Since deployment is the only time this code runs, the system uses and tosses it, and does not actually store it on the chain.
    For MightyBlockCoin we want to limit wallets to a maximum of 10 MBC per transfer. Our constructor will set maxTransferAmount to 10.
  • Storage definition: These are your persisting variables, where you will keep useful information for the usage of the contract. You have the well-known integers, strings and bools and also complex data structures that go by “structs” on Solidity, but the most useful ones are mappings that basically work as non-iterable dictionaries with very fast access by key.
    Our ERC20 will need to keep track of balances, for such purpose there will be a mapping(address => uint256) this means a dictionary where the wallet addresses are the keys and their balances are the values, we also need to store the maxTransferAmount that we set on the constructor.
  • View methods: Allow the user to access a piece of information without modifying the storage-state and incur no gas cost, thereby not making all transactions equal.You can try to restrict access to view methods, but it’s generally a bad practice to do so and the barrier is easily avoidable by skilled inquirers.
    In our example, we would have a getBalance method where walletAddress is the parameter and we return the MBC balance of such wallet.

Next steps of a smart contract structure

  • Storage-modifying methods: Methods for security, access, consistency, and permission checks, which allow storage to mutate, form the backbone of a smart contract. When these checks pass, the system performs the storage altering actions.
    The transfer function for MBC validates that the sender has enough balance and the transfer amount is lower (or equal) than maxTransferAmount. Lastly it stores the new balances for both the sender and the receiver.
  • Events: Transactions on the blockchain do not provide any response other than the fact that it executed. We emit personalized events defined on the contract to keep some type of log of what happened. Events come with a name and parameters, they are the basic tool that most platforms use to keep track of what’s going on.
    For an MBC transfer we would want a Transfer event with parameters sender, receiver and transfer amount.

EVM vs NO EVM + testing

Venturing further into the realm of developing smart contracts, it’s crucial to grasp the landscape of blockchain ecosystems and programming languages that power them.

We can broadly categorize blockchain platforms into those that utilize the Ethereum Virtual Machine (EVM) and those that don’t. EVM-based blockchains, like Ethereum blockchain itself, offer a standardized execution environment for smart contracts, ensuring consistency across different nodes. On the other hand, non-EVM blockchains networks, such as Algorand and Solana, employ their own unique execution environments optimized for specific purposes.

smart-contract-developer

When it comes to programming languages for a smart contract developer, Solidity stands tall as the primary choice for Ethereum-based contracts. It is a statically-typed language specifically with a design for writing smart contracts. That is the importance of Solidity smart contract development.

Vyper is another language for Ethereum network that focuses on security and simplicity, making it a preferred option for scenarios where code clarity is paramount. Beyond Ethereum, Rust has gained attention for its use in the Solana blockchain due to its efficiency and safety features.

Testing and developing smart contracts

But programming languages are just one piece of the puzzle. Testing and development environments play a crucial role in ensuring the reliability of a simple smart contracts. Tools like Hardhat, a JavaScript-based development environment, and Brownie, its Python counterpart, provide testing, deployment and debugging capabilities.

They enable developers to simulate blockchain environments locally, helping to catch errors and security vulnerabilities before deployment. These tools offer sophisticated testing frameworks and integration with popular testing libraries, enabling developers to write comprehensive test suites to ensure contract functionality and security.

Navigating the landscape for smart contract developer involves understanding the nuances of EVM and non-EVM blockchains, choosing the right programming language for the job, and utilizing robust testing frameworks. As the ecosystem evolves, developers need to stay adaptable, continually learning and adapting their skills to keep up with the dynamic world of blockchain technology.

New challenges in web3

Testing

Our experience with testing Solidity has been quite challenging, for our particular use case and technology stack, we decided that Python + Brownie suited us best.

The reality of the matter is that Brownie emulates a real environment locally.This means that deploying smart contracts is necessary for sending transactions against them. Since you can only interact with the public/external methods, the ability to create unit tests is limited, as calling internal or private methods is not possible.

smart-contract-development

Deployment

Deploying smart contracts can be even more challenging than testing. Usually developers and owners are different people, this means that a developer might not have access to the private key, which in turn means that someone else, following the dev’s lead, has to send the transaction with the owner wallet.

Since smart contracts code are immutable by design, each deployment is a big deal. For that reason we work to ensure that the experience is secure, smooth and seamless as there are no rollbacks. In practical terms, for every deployment that we schedule, we plan ahead and create a checklist with the step by step guide of what to do, which commands to run and in what given order.

Security

The mix of the monetary value stored inside a contract and its immutability makes thinking about security crucial ahead of time, as rules cannot change on the fly. On top of that, every transaction is independent, there is no such thing as a session, it must check all possible scenarios every time to ensure that only the intended usage is the allowed usage.

Any open exploits serve as entry points for hackers and malicious actors, and even when detected, the issue remains unfixable since altering the contract is not possible.

Technical limitations of Solidity

There are no floating point numbers, this leads to using integers to store numbers with decimal places, making it sometimes confusing to know the number’s scale.

Another impractical limitation is Solidity’s inability to keep complex data structures in storage, requiring the developer to find a workaround to store the data in a more complex but Solidity-friendly way.

Thirdly, an arch enemy of the developer is Solidity’s impossibility to handle dynamic size arrays. For example, when searching all elements that meet certain condition, the data must be looped through once to determine the array’s size and then one extra time to populate said array with the matching elements.

Last in this list but definitely not least is the infamous “stack too deep” error, which appears when too many variables are being used in the context of one given function, forcing workarounds to remove variables or reorganize code into separate smaller functions until the error is gone.

Liveops

Once the contract has been deployed, all types of issues may arise, the blockchain scanner, blockchain query tools amongst other, are essential tools to master to be able to handle such scenarios. This usually entails following transactions around and reading logs/events until the root cause unravels.

Paradigm shifts

It’s quite common to encounter accesibility modifiers on functions such as public and private when working on a Web 2.0 project. In Solidity, 2 other visibilities must be taken into account including external and internal, security concerns of each option should be considered when using them.

The next big paradigm shift comes in the form of storage types. Storage is used in situations where memory isn’t best suited and viceversa, mastering the usage of storage types is essential as they are mandatory for most variable declarations. Finally, units are stored in different scales, most values might need some multiplication or division by 10**18 to account for the difference between wei and eth values.

External resources

Managing third party information requires workarounds as there are no APIs you can call or external resources you can access easily. Calling other contracts requires you to store their address and importing their interface in order to interact with them. The challenge of getting external information becomes substantial and oracles come to fill that void. Oracles are paid services that offer on-chain information that is not easily accesible otherwise, they represent to web3 what public APIs do for web2.

Language caveats

How would you sort an array of elements in Java? Well, you would simply call Array.sort(), that’s not an option in Solidity. Usually builtin methods entail a trade-off between performance and readability. Solidity is not willing to trade performance off, since performance is gas and gas is money. There are options like OpenZeppelin, which provides a library of frequently used methods to make the code more readable while still performing best practices. Nonetheless, implementing the methods for this basic operations still tends to be the best option. Other missing methods in Solidity are: min, max, filter, removeAt, foreach, etc.

Conclusions from a smart contract developer

As we conclude this epic journey through the realm of a smart contract developer, it’s evident that the digital landscape is undergoing a transformation unlike any other. The shift from Web 2.0 to Web 3.0 signifies a pivotal moment where decentralization, security, and user empowerment take center stage.

In the world of smart contracts, we’ve delved deep into their structure, the intricate web of challenges and opportunities that await the intrepid developer. Testing and deployment have proved to be crucibles where code is refined, ensuring the reliability of smart contracts. Security remains paramount, as every line of code written in the blockchain is etched in history, unalterable by design. Technical limitations and paradigm shifts have been embraced as challenges, not obstacles, by the developers pioneering this new era.

In this brave new world, we’ve witnessed the rise of oracles, the intricacies of storage types, and the relentless pursuit of performance. The absence of built-in methods has sparked creativity, making the Solidity developer a master of their craft.

Through it all, we’ve come to realize that Web 3.0 is not just a technological shift; it’s a philosophical one. It champions the ideals of decentralization, data sovereignty, and transparency. As the blockchain ecosystem continues to evolve, adaptability and continuous learning become the armor of the smart contract developer.

We are waiting for your talent like smart contract developer

So, fellow adventurers in the digital realm, take these learnings with you as you embark on your journey into the ever-expanding universe of smart contracts. From the humble lines of code to the immutable contracts etched in the blockchain, you are the architects of a decentralized future, where trust is forged in code and the magic of Web 3.0 becomes a reality.

As the digital frontier beckons, remember, you are the pioneers, the masters of blockchain’s arcane arts, and the guardians of a more equitable and decentralized digital world. The future awaits your code.

We are always looking for Web3 talent !

Mighty Block is one of the partners of Forte, a platform to enable game publishers to easily integrate blockchain technologies into their games. We believe blockchain will enable new economic and creative opportunities for gamers around the world and have assembled a team of proven veterans from across the industry (Kabam, Unity, GarageGames, ngmoco, Twitch, Disney), as well as a $100M developer fund & $725M funding, to help make it happen. That’s where you come into play.

Feel free to browse all our current open job opportunities in the following link 👇

The Web3 Glossary

Web3 Glossary

The blockchain world can be overwhelming at first. Having a deep understanding of the basic concepts will help you better organize your learning process. Here are some definitions we have crafted to help you get started with, we introduce you: “The Mighty Block Web3 Glossary”.

(in alphabetical order)

Airdrop : Describes token distribution methods used for introducing new cryptocurrencies or tokens to specific wallet addresses. Web3 projects can use airdrops as marketing initiatives by facilitating airdrops to users completing tasks such as app downloads or referrals.

Altcoin:  Any of various cryptocurrencies that are regarded as alternatives to established cryptocurrencies and especially to Bitcoin.

Arbitrum: Arbitrum is an Ethereum layer 2 scaling solution that reduces fees and network congestion by computing transactions outside of the Ethereum Mainnet. Arbitrum’s rollups use multi-round fraud proofs to verify contracts were executed correctly. Blocknative currently does not support the Arbitrum L2 blockchain.

Arbitrum

Arbitrage: Arbitrage in the world of web3 is the same as in traditional finance and is a natural mechanism for markets to achieve equilibrium. Whereas arbitrage in the real world is usually possible due to differences in physical realities (the price of a widget is 20% higher in Country A than Country B), arbitrage in web3 is made possible by the value of assets within different web3 ecosystems. Consider a situation where the price of Ethereum is $2000 on Uniswap, but at the same time, it is $1990 on Sushiswap. An arbitrager can take advantage of this gap by buying ETH on Sushi to resell on Uniswap, instantly pocketing $10 per ETH (minus gas fees). Arbitrage is a key factor in MEV.

Blockchain: A blockchain is a distributed database that is shared among the nodes of a computer network. Blockchains store a continuously growing historical ledger of information (e.g. accounts and transactions) into blocks. Blocknative builds APIs for blockchain developers, including mempool monitoring tools, blockchain notification tools, and gas estimation tools.

Bridge: The list of essential terms in web3 would also draw attention toward bridges, which have emerged as promising answers to concerns of interoperability. The bridge is an effective tool tailored for transferring assets from one blockchain network to another. It is also important to note that all bridges do not feature the same design and have different functionalities.

Centralized Exchanges: Centralized exchanges have evolved as one of the popular applications in the web3 ecosystem with promising value advantages. Centralized exchanges are cryptocurrency exchanges run by third-party agencies to sell and buy cryptocurrency. One of the distinctive highlights of centralized exchanges is the fact that they are custodial in nature. Notable examples of centralized exchanges include Gemini, Kraken and Coinbase. 

Decentralized Exchange (DEX). This type of crypto exchange enables users to transact in a direct peer-to-peer manner without any intermediary

ERC: Ethereum Request for Comment is the proposal for modification to the Ethereum ecosystem, which has passed the approval stage. It points out a collection of standards used for a specific operation on the Ethereum network. 

Gas: Gas is a unit of measurement that represents the computational effort required to complete a transaction. How much a user spends to complete a transaction is determined by the total amount of gas multiplied by the gas price.

Gas Estimator: Gas Estimator is an ETH gas fee tracking tool built by Blocknative that inspects every pending transaction in Ethereum’s mempool to probabilistically estimate transaction fees to get included in the next block.

Gas Fees: Gas fees are the fees users must pay in Ethereum’s native currency, Ether (ETH), to complete a transaction. Gas fees are used to compensate miners for providing the computational work required to process and validate transactions.

Gas Price: The gas price is the amount of Ether (ETH) a user is willing to pay for every unit of gas required to complete a transaction (denominated in Gwei).

Layer 1: refers to the main blockchain in a multi-level blockchain network. For example, Ethereum and Bitcoin are layer one blockchains. Many layer two blockchain offload resource-intense transactions to their separate blockchain, while continuing to use Ethereum’s or Bitcoin’s layer one blockchain for security purposes.

Layer 2 (L2) refers to a secondary framework or protocol that is built on top of an existing, layer one blockchain. Layer 2 blockchains typically improve transaction speeds and cost efficiency. As Layer 2s continue to scale, mempool data gives builders looking to migrate or build new Dapps the tools to create the best user experiences.

Liquidity Pool: Is a smart contract containing large portions of cryptocurrency, digital assets, tokens, or virtual coins locked up and ready to provide essential liquidity for networks that facilitate decentralized trading.

Oracles: Are entities that connect blockchains to external systems, thereby enabling smart contracts to execute based upon inputs and outputs from the real world. Oracles provide a way for the decentralized Web3 ecosystem to access existing data sources, legacy systems, and advanced computations.

POH: Proof of Humanity (or PoH) is a social identity verification system for humans on Ethereum. PoH combines webs of trust, reverse Turing tests, and dispute resolution to create a sybil-proof list of humans.

Smart Contract: The smart contract is written in virtual language and has the power to execute and enforce itself, autonomously and automatically, based on a series of programmed parameters. With blockchain technology, its main value lies in reinforcing security, transparency and trust between signatories, avoiding misunderstandings, falsifications or alterations and dispensing with intermediaries.

Staking: Staking is the locking up of cryptocurrency tokens as collateral to help secure a network or smart contract, or to achieve a specific result. Staking is a term often used to describe the locking up of cryptocurrency as collateral to help secure a particular blockchain network or smart contract protocol

Swapping: An agreement between two parties that exchange different token types (say token 𝐴 and token 𝐵). In a token swap, one party will pay a certain amount of token 𝐴 to the other party and receive the agreed amount of token 𝐵 in return.

Wallet: A Web3 wallet is a software program that stores private keys, which are necessary for accessing blockchain networks and conducting transactions. Unlike traditional wallets, which store physical currency, Web3 wallets store digital assets such as Bitcoin, Algorand, and NFTs.

Zero-Knowledge Proof: A zero-knowledge proof is a method of verification in which a “prover” shows possession of secretive knowledge to a “verifier” without revealing the sensitive information itself. This encryption scheme can ensure data privacy and confidentiality on a public blockchain.

ZK-Rollup: A ZK or “zero-knowledge” rollup is an Ethereum layer 2 scaling solution that bundles transactions off-chain into a single cryptographic proof. This transaction is then submitted back to the main chain for validation. ZK-rollups utilize validity proofs to confirm transaction legitimacy.

We are always looking for Web3 talent !

Mighty Block is one of the partners of Forte, a platform to enable game publishers to easily integrate blockchain technologies into their games. We believe blockchain will enable new economic and creative opportunities for gamers around the world and have assembled a team of proven veterans from across the industry (Kabam, Unity, GarageGames, ngmoco, Twitch, Disney), as well as a $100M developer fund & $725M funding, to help make it happen. That’s where you come into play.

Feel free to browse all our current open job opportunities in the following link 👇

Arbitrum: The Answer to Ethereum’s Scalability Challenge?

Arbitrum

As you may know, Ethereum is the leading blockchain for implementing smart contracts. Despite notable progress made in enhancing scalability through the implementation of the Shanghai update, the Ethereum network supports a limited range of 20-40 TPS (transactions per second). This capacity falls short in meeting the demands of its expansive user base, leading to high transaction fees and sluggish processing times. In light of these challenges, the introduction of Arbitrum Ecosystem offers a promising solution to address these concerns and reshape the Ethereum landscape.

What is Arbitrum?

Arbitrum is a Layer 2 (L2) solution for Ethereum that enhances the user experience by enabling faster and more cost-effective transactions, with the capacity to handle up to 40,000 TPS. Is composed of two distinct chains, Arbitrum Nova and Arbitrum One, each chain serves specific real-world use cases.

Arbitrum One uses a rollup protocol, wherein the correct behavior of the Arbitrum Virtual Machine (AVM) is ensured by a single honest node. This chain offers a versatile platform for running Ethereum-compatible smart contracts, providing scalability and cost-efficiency. By employing optimistic execution, Arbitrum One considers all transactions valid unless a node identifies suspicious activity. Validators can participate by running the required software and staking Ethereum.

On the other hand, Arbitrum Nova adopts the anytrust protocol, catering to applications that prioritize high transaction throughput over complete decentralization (for example web3 games). While sacrificing some decentralization, Arbitrum Nova delivers enhanced speed and reduced transaction fees under the management of a 20-member Data Availability Committee (DAC), responsible for expediting the storage, batching, and posting of L2 transaction data to Ethereum’s Layer 1 (L1).

Arbitrum Ecosystem

Since its launch on the Ethereum mainnet in August 2021, Arbitrum has experienced remarkable growth. Many users have started using it, and there are now 525 projects using Arbitrum’s network.

Arbitrum made a significant change by becoming a decentralized autonomous organization (DAO). As part of this shift, they launched an airdrop program in March of this year. Users and community members had the opportunity to complete certain tasks and interact with the network to qualify for the airdrop. The main goal of the airdrop was to encourage more people to join and strengthen the community.

Today, Arbitrum has become one of the top projects in the cryptocurrency world, showing impressive growth. The following image presents some important numbers that highlight the achievements of the Arbitrum ecosystem:

These numbers demonstrate the success and growth of the Arbitrum project, showing its increasing prominence in the crypto industry.

Arbitrum Ecosystem vs other L2s

Even though Arbitrum has made significant progress in attracting new developers and users, it faces tough competition from other platforms. Let’s take a look at two of its main rivals:

  • Polygon is a sidechain that uses the proof-of-stake (PoS) mechanism for reaching agreement on transactions. It is only compatible with Solidity and Vyper, which are two programming languages for Ethereum’s virtual machine (EVM). Polygon boasts a higher transaction speed of 65,000 TPS and has its own native token called $MATIC. Since Polygon operates as a sidechain, it has its own separate consensus mechanism and operates independently of the Ethereum mainchain. While this gives it more freedom, it also means it doesn’t directly inherit Ethereum’s security. If something goes wrong on Polygon, it could potentially compromise assets without affecting the main Ethereum chain.
  • Optimism is also an optimistic rollup chain that uses Ethereum’s consensus protocol. It is compatible only with Solidity, similar to Polygon, as both use the Ethereum Virtual Machine (EVM). However, Optimism has a lower transaction speed of 2,000 TPS. One of the key differences between Optimism and Arbitrum is that Arbitrum uses its own AVM (Arbitrum Virtual Machine). This distinction brings some benefits to Arbitrum, as it is not as tightly coupled to Ethereum as Optimism, which may provide greater flexibility and opportunities for future developments.

So while Arbitrum faces strong competitors like Polygon and Optimism, its unique features and capabilities, such as the AVM, set it apart from the rest and could prove advantageous in the evolving landscape of blockchain technology.

How to bridging tokens to Arbitrum ecosystem

Arbitrum Bridge allows users to transfer their assets from Ethereum to Arbitrum Nova or Arbitrum One. Assuming you already have Metamask installed, follow these steps to get started:

  1. Add the Corresponding Network: In this example, we’ll focus on Arbitrum One, but the same process applies to Arbitrum Nova. Add the network details as follows:

Network Name: Arbitrum One

New RPC URL: https://arb1.arbitrum.io/rpc

Chain ID: 42161

Currency Symbol: ETH

Block Explorer URL: https://arbiscan.io

  1. Then you should visit bridge.arbitrum.io and login with your wallet. You will see the following:

  1. Choose the token you wish to bridge and specify the corresponding amount. A summary will be displayed, indicating the costs and the total amount you are about to transfer.
arbitrum
  1. Once you are satisfied with the details, accept the transaction. This initiates the asset transfer process.

That’s it! You have successfully transferred your assets from Ethereum to Arbitrum One. The process for withdrawing assets follows the same steps, with the only difference being the selection of the “From” and “To” networks.

Final thoughts

In conclusion, Arbitrum Ecosystem has emerged as a promising Layer 2 (L2) solution within the Ethereum ecosystem. It offers significant improvements in transaction speed and cost-effectiveness, addressing the scalability challenges faced by the Ethereum network. Since its launch, Arbitrum has experienced impressive growth, attracting a diverse range of projects and establishing itself as one of the top players in the cryptocurrency world.

However, it is crucial to acknowledge that Arbitrum faces stiff competition from platforms like Polygon and Optimism. Polygon’s higher transaction speed and independent consensus mechanism, coupled with Optimism’s compatibility with Solidity, pose significant challenges to Arbitrum’s quest for dominance.

While Arbitrum has unique advantages, such as its AVM and seamless compatibility with Ethereum, it still has room for further development and refinement. It needs to address these challenges head-on and continue to innovate to secure its position as the go-to solution for scaling Ethereum effectively. It will be fascinating to see how it evolves and competes against its rivals in the race to become the number one project for scaling Ethereum.

We are always looking for Web3 talent !

Mighty Block is one of the partners of Forte, a platform to enable game publishers to easily integrate blockchain technologies into their games. We believe blockchain will enable new economic and creative opportunities for gamers around the world and have assembled a team of proven veterans from across the industry (Kabam, Unity, GarageGames, ngmoco, Twitch, Disney), as well as a $100M developer fund & $725M funding, to help make it happen. That’s where you come into play.

Feel free to browse all our current open job opportunities in the following link 👇

The Mighty Block podcast

Mighty Block podcast

If you’re interested in blockchain technology, gaming and then our podcast is for you!

Listen to experts in the field discuss the latest developments and future potential of using blockchain, the latest news related with blockchain technology and the gaming industry.

Tune in to stay informed and ahead of the curve in the world of blockchain and gaming:

Episode 9: Educación y Seguridad en Web3

In this episode, we chat with Pablo Sabbatella about Education and Security. Two concepts that go hand in hand and are key when onboarding the next billion users of Web3.

Episode 8: Puede Blockchain desplazar a las bases de datos relacionales?

We chat with Javier Villegas, an expert in relational databases, about the differences between various types of storage. Additionally, we discussed the technology that best applies to each specific case.


Episode 7: Descentralizando la identidad con Web3

If you’re interested in learning more about decentralized identity in Web3, then you won’t want to miss our latest podcast episode. Our expert guests, Milton Berman, share their experiences and insights into the potential of decentralized identity.

In this episode, you’ll learn about the benefits of decentralized identity, including increased privacy and security. Our guests also discuss the practical applications of this technology.

Whether you’re a developer, entrepreneur, or simply curious about Web3, you’ll find something valuable in this episode. So be sure to tune in and discover the potential of decentralized identity for yourself!

Episode 6: Emprender en Web3

Check out our latest podcast episode featuring the CEO and founder of Mighty Block, Franco Breciano. In this episode, we dive deep into the world of web3 and the future of the business ventures in this exciting new space.

Episode 5: De space invaders hacia Crypto traders

Recommended for gamers and those who want to learn more about this world! How have video games evolved to web3? What is coming in the future? In this episode, Sebastian Perez (Tech Lead at Mighty Block) and Uri Chami (Solidity Developer at Mighty Block) discuss these topics.

Episode 4: El camino de Web2 a Web3

In this episode we talk with our guest Milton Berman, WakeUp Labs founder and CEO, about the process through web2 to web3

Episode 4: Resumen del mundo Crypto 2022

2022 was a year of unprecedented events for the cryptocurrency ecosystem. With Diego Gurpegui Improve-in Co-founder and CTO we took a look back at the most important events of the year.

Recommendation: Visit our blog to more web3 news

Episode 2: Bitcoin vs Ethereum: The final game.


Bitcoin and Ethereum are the world’s most popular blockchain networks. We discuss with Diego Gurpegui Improve-in Co-founder and CTO about the differences and benefits of each one.

Episode 1

In our first episode we talk with Emiliano Canedo (web3 researcher and digital artist) about Ethereum: The merge, the history and the future.

We are always looking for Web3 talent !

Mighty Block is one of the partners of Forte, a platform to enable game publishers to easily integrate blockchain technologies into their games. We believe blockchain will enable new economic and creative opportunities for gamers around the world and have assembled a team of proven veterans from across the industry (Kabam, Unity, GarageGames, ngmoco, Twitch, Disney), as well as a $100M developer fund & $725M funding, to help make it happen. That’s where you come into play.

Feel free to browse all our current open job opportunities in the following link 👇

Upgradeable Contracts: An introductory guide

ETH

One of the first things we learn in Solidity/Ethereum is that contracts are immutable. If you upload a contract on the blockchain, you can’t change its source code and therefore you can’t change its logic.

We must be extremely careful with the code we use: if we make one simple mistake it could be extremely expensive. That’s why we consider alternatives as a way to avoid this limitation. Let’s see how we can use an upgradeable contracts.

Contracts Old School

The simplest thing we can do is upload a new version of the contract (and thus a new deploy and a new address). But this has its issues, for example let’s think about what it was like to have a shop a few years ago (before the internet). If we wanted to move to another address, we had no way of notifying all our clients and potential future clients of this change. The same thing happens in smart contracts, all users must know that the address has changed, but not having a user registry makes it very difficult.

Example no upgradeable contracts

Ways to create a upgradeable contracts

There are currently 4 ways to create an upgradeable contracts.

Using an interface / proxy

Taking advantage of inheritance and polymorphism, an interface with the contract structure can be exposed. So now we have two contracts: one with the contract definition (and external calls) and the other with the function’s implementation. The user interacts with the contract through the interface and if an update is required, the address of the contract is simply changed for the new version in a simple variable inside the contract.

Example upgradeable contracts

It is not possible to modify the contract’s structure since we MUST respect its interface, but its main disadvantage is that the stored values ​​will remain in the contract that has the logic, and if we want to update it with that of another contract, we will lose the storage state.

What is done to solve the storage issue is to have a “proxy” contract that has the same structure as the one with the logic, and it is accessed through the delegatecall instruction. It is SUPER IMPORTANT to keep the same variable structure in the contracts since we will be sharing the storage, and if both do not have the same variable structure, a collision could occur. A possible solution for this is that they both inherit from a base contract that sets the same variable-structure for all of the contract versions.

Example upgradeable contracts

It seems to be a better alternative but in terms of gas it is expensive: we are always adding variables that we will most likely never use in every logic contract we implement. This can be improved if a third-party storage contract is used, for this, we can use solutions such as OpenZeppelin or combine it with an unstructured storage.

OpenZeppelin Transparent Proxy

If you are a user of the OpenZeppelin contracts you have noticed this plugin for sure. Inside, it uses a mechanism known as Transparent Proxy, which uses unstructured storage to avoid collisions (as long as we add the variables at the end and never at the beginning). This proxy is already integrated as a plugin and is compatible with Hardhat and Truffle.

Link here

Diamond Pattern

This is one of the most popular and most complex, since we have an intermediary contract, but instead of aiming for a single final contract, each function will be implemented in a different smart contract. In addition, each “Facet” contract (as they are called) will have a fixed memory space to avoid collisions. A major advantage is, a whole contract deployment is not required, just a contract with one function implementation. That’s cheaper than deploying a complete-structure contract with all of the functions and also as there is just one function per contract, the size limit is very hard to reach. It is undoubtedly the favoured solution for the complex scenarios that are created today and there is even an EIP that refers to it.

Example upgradeable contracts

Link here

Syntethix Router Proxies

At ETH Latam event, Alejandro Santander (known as The Ethernaut) presented a solution called Router Proxies. It is quite similar to the Diamond Pattern, but simpler. I recommend watching this talk!

Link here

Video here

Metamorphosis Smart Contract

What? Well, we are not actually modifying the contract, but if we had the ability to remove the contract from storage, we could force a deployment to that same address, then replace one contract with another. And this is how this technique works. Through the selfdestruct() statement, it is possible to remove a contract from the blockchain storage, and using the create2 operation, a new version of the contract is deployed to THE SAME ADDRESS.

Example upgradeable contracts

Link here

Ok, but… is it okay to modify a Smart Contract?

In centralized software, not only is this not a bad thing, it is a necessary thing. What happens in decentralized projects? Who should update the code? Is a DAO reliable enough? On the one hand, an immutable contract seems more reliable than an upgradeable contracts but it also makes it more vulnerable to attacks. In my opinion, it is good to consider all these alternatives and use them if the project requires a sophisticated architecture. Making a contract upgradeable makes its code much harder to understand and trace, but improves its resistance to attacks. If the strength of a project is its simplicity, I would not work on making the contract updatable, but I would do so in complex projects with multiple contracts.

We are always looking for Web3 talent !

Mighty Block is one of the partners of Forte, a platform to enable game publishers to easily integrate blockchain technologies into their games. We believe blockchain will enable new economic and creative opportunities for gamers around the world and have assembled a team of proven veterans from across the industry (Kabam, Unity, GarageGames, ngmoco, Twitch, Disney), as well as a $100M developer fund & $725M funding, to help make it happen. That’s where you come into play.

Feel free to browse all our current open job opportunities in the following link 👇