Using the voting smart contract with scripts
You developed the voting smart contract in the previous chapter. But you only wrote the smart contract and the unit test. You haven’t yet deployed the smart contract onto the blockchain. To use the voting smart contract, you need to deploy it first.
Compiling the smart contract
Let’s set up the Python environment and install the necessary libraries:
$ python3.10 -m venv .venv $ source .venv/bin/activate (.venv) $ pip install --upgrade pip (.venv) $ pip install eth-ape'[recommended-plugins]'==0.7.23
Then, create a project directory:
(.venv) $ mkdir voting_app (.venv) $ cd voting_app
As usual, you initialize the project directory with the ape
command and give the name VotingApp
to the project:
(.venv) $ ape init Please enter project name: VotingApp SUCCESS: VotingApp is written in ape-config.yaml
Then, you should create VotingApp.vy
inside the contracts
folder. You should use the same content of...