Write the Smart Contract
We’ll start our Dapp by writing the smart contract that acts as the back-end logic and storage.
You might have heard about ERC-20, which is a token standard in Ethereum. Tokens such as DAI and USDC implement the ERC-20 standard which allows them all to be compatible with any software that can deal with ERC-20 tokens. For the sake of simplicity, the token we're going to build does not implement the ERC-20 standard.
Create a new file named
Token.sol
in thecontracts/
directorynoteCopy the following code:
The source code above is just an example to illustrate how your source code looks like. In practice, your source code may contain one or many files with complex structure.
Compiling
Solidity is a compiled language, meaning we need to compile our Solidity to bytecode for the Ethereum Virtual Machine (EVM) to execute. Think of it as translating our human-readable Solidity into something the EVM understands.
Viction is EVM-compatible, which means that every contract written in Ethereum can be seamlessly ported to Viction without effort.
To compile the contract run npx hardhat compile
in your terminal. The compile
task is one of the built-in tasks.
You should see output similar to the following:
Last updated