Deploying a smart contract
To deploy a smart contract, you need a smart contract first. So, let’s create a smart contract. Create a file named SimpleContract.vy
and add the following code to it:
# @version ^0.3.0 event Donation: donatur: indexed(address) amount: uint256 num: uint256 @external def store(num: uint256): self.num = num @external def retrieve() -> uint256: return self.num @external @payable def donate(): log Donation(msg.sender, msg.value)
This smart contract has a method named retrieve
to get the value of the num
state variable. It also has a method named store
to change the value of the num
state variable. Lastly, it has a method named donate
to accept ETH.
Now, you need to compile the smart contract into the bytecode and the ABI. Let’s save them in files. To do this, first, you need to install Vyper:
(.venv) $ pip install...