This guide is focused around understanding Ethereum, Smart Contracts, Metamask and transactions.
Jump to a section:
- What is Ethereum?
- What is Metamask?
- What is a transaction?
- What is GWEI and GAS?
- What exactly is a Smart Contract?
- How are DApps like P3D created?
What is Ethereum?
Ethereum is a network of thousands of nodes that are running all over the world. Anyone can run a node in that network, and each node is running the Ethereum virtual machine which implements the rules of the system. Each node downloads all transactions that have happened ever (kinda) and has the balance of every Ethereum account. An Ethereum account is represented by an Ethereum address, a balance, and a private key.
An Ethereum account can transfer part of its balance to another account, but you need to sign the transaction with the private key. Once you create the transaction in a node, it will propagate to the other nodes. Therefore, if you lose/publish your private key, anyone can transfer balance out of that account.
For a more comprehensive overview of Cryptocurrencies and Blockchain, please check out this Hackernoon guide.
What is Metamask?
Metamask is a browser extension for Firefox or Chrome that acts as a gateway between the Ethereum blockchain and standard browsers. MetaMask is also a wallet that can store multiple addresses and private keys for you. You can also use Metamask to send, receive, and buy Ethereum and Ethereum-compatible tokens directly through this browser extension.
More than being a wallet, MetaMask manages multiple identities for you when using Ethereum Dapps. You can log into one Dapp with one address. Then you can interact with another dapp using an unrelated address. Once you learn how to use MetaMask effectively, it keeps your identity private and your data disconnected from each other.
What is a transaction?
Blockchains and smart contracts operate based on discrete units of data that are recorded onto a digital ledger (chain). Transactions on Ethereum tend to consist of a target contract or address, an amount of Ether, and a custom "message" which can contain arbitrary info.
You post transactions onto the Ethereum blockchain, which are sent from your Metamask to an arbitrary Ethereum wallet address or smart contract. Once the transaction has been completed, the transaction must be processed and will then either show in the address or the request will be processed by the smart contract. Note that to send transactions, you need to include GAS to power the completion of your request as explained below.
What is GWEI and GAS?
GAS is a fixed unit used to represent the complexity of a transaction on the ETH network. A wallet to wallet transaction is the least complex transaction you can have therefore it uses the least amount of GAS, namely 21,000 GAS. Transactions to smart contracts often involve logic, and therefore they are more complex, hence cost more GAS.
gwei is the ETH unit used to pay for the GAS, i.e. used to designate the GAS price
so for a normal wallet to wallet transaction with 21,000 GAS and a GAS price set at 10 gwei, you would pay
21,000 GAS * 10 gwei/GAS = 210,000 gwei.
1 gwei == 0.000000001 ETH (or
1000000000 gwei == 1 ether). For an easy to use calculator converting GWEI to ETH values, check out the ethconverter.
Why do Ethereum transactions require GAS?
A smart contract contains commands executed by a computer. This means that when a smart contract runs, it consumes someone’s computing power like a car engine consumes gasoline. This someone needs to be paid for the provided computing resources.
Every command in a smart contract is a price measured in terms of gas. Some commands cost more, some commands cost less but they are never free. Now, an interesting thing about Ethereum is that while each command has a predetermined and fixed cost in terms of gas, gas price is not actually fixed.
In short, the GAS is used to pay the people running software to process your transactions on the Ethereum blockchain. Think of this as a bounty (reward) for them to accept and process your request.
Why do GAS prices change in value?
Whenever a smart contract is invoked, the sender can specify how much they are willing to pay for gas for that transaction. On the other hand, people whose computing resources are used (miners) decide whether to accept the proposed price or not. Obviously, miners try to maximize their profit and thus they are looking to accept transactions with higher gas price.
When there are a lot of requests on the network, the network is "congested" and since there are so many requests, people will start using higher gas prices. As the gas prices rise, others increase their prices even higher to have their transactions completed first. The miners are looking to process transactions that provide them the best rewards.
In this way, as there are more requests being processed, the price you need to pay for your transaction to be processed in a timely fashion can fluctuate wildly. You can check the recommended gas prices here at anytime. We recommend you use near the "Fast" GWEI whenever possible for best results.
What exactly is a Smart Contract?
A smart contract is a set-in-stone code program that is deployed to the Ethereum (Eth) network. The smart contract handles all ETH and tokens autonomously without any form of human input, and its calculations and functions are confirmed across thousands of computers across the world before they are run.
You write a contract in a programming language called Solidity and store it directly onto the Ethereum network, and it will be assigned an address. Once a contract has been stored at an address, the code can't ever be modified. Anyone can interact with a contract at an address by invoking its functions from any Ethereum node.
Understanding How Contracts Work
The core functionality of this exchange/game is powered by a deployed open-source Ethereum smart contract. Smart contracts are immutable and this means there is no one who has access to these funds but this autonomous program.
Smart contracts require an Ethereum transaction to be sent for every action taken. This means that every action you take on the exchange requires a transaction to be sent through by the user on the Ethereum network. All actions including buying keys, withdrawing from your vault, picking a vanity name, etc, require a "0" ETH transaction to be sent (with GAS which costs Ether, make sure you account for this!). This is why you see so many "0" ether transactions here.
Let's define the basics of a few terms before continuing on in this guide:
- Blockchain - A complete digital record of transactions (distributed ledger) that have happened that cannot be easily forged or altered. Simply put, a distributed database of currency transactions. The name refers to the “chain” of data chunked into discrete "blocks", each containing transaction history.
- Transaction - Blockchains and smart contracts operate based on discrete units of data that are recorded onto a digital ledger (chain). Transactions on Ethereum tend to consist of a target contract or address, an amount of Ether, and a custom "message" which can contain arbitrary info.
- Smart Contract - Think of smart contracts as a computer program that runs on the Ethereum blockchain which, once deployed, can not have code directly modified. This program can do most anything but is often used to accept digital currency and then coded to perform specific purposes (games, arbitration, etc).
- Metamask - Browser extension for Firefox or Chrome that acts as a gateway between the Ethereum blockchain and standard browsers acting as an account for the user and also allows the sending and receiving of Ethereum or compatible tokens.
What skill-sets are needed to develop a project like P3D?
To design, develop and deploy a successful Ethereum DApp project (Decentralized Application) such as P3D requires a wide-range of skill-sets and technologies between the contributing team members:
- Product Lead - All projects require a project lead (or leads) that have a clear vision of a product they want to see developed. This involves an understanding of a project (or game) that at its core is interesting, innovative and worthy of attention. None of the technology matters unless there's a project worth building.
- Visual Designers - The development of innovative projects also requires a clear brand and visual style. In the case of some projects, this is high-quality logos, color schemes, visual flair, and graphics. In the case of P3D, this also means the development of cool memes and illustrations. A great product often requires a great design in order to achieve its goals.
- Solidity Smart Contract Engineers (Solidity) - At the heart of P3D is an exchange that can accept Ethereum and provide P3D tokens, selling tokens for Ethereum, and allowing the withdrawal or reinvestment of rewards. This functionality is powered by an underlying smart-contract deployed to the Ethereum blockchain. Smart contracts on the Ethereum network are developed with a special language called Solidity. The code for this contract can be found on the blockchain through Etherscan.
You can see a visual illustration of the Ethereum dapp stack here:
If you are interested in learning about developing in Solidity or creating DApps, anyone can learn if they are willing to put enough time and energy. Check out our introduction to Dapp development for a great starting point and links to resources.