1/5
## How to Deploy a Contract to the EVM In this lesson, we'll cover how to deploy a contract to the EVM. You'll see how to create a transaction object and build a contract. ### The 'To' Field We are going to go over why the 'To' field in our transaction object is blank. When you deploy a contract to the EVM, you make the 'To' section of your transaction object blank. For example, if we were to take this transaction object and update the 'To' field, we could type: ```python transaction["to"] = ``` This will make the transaction no longer a contract deployment. Instead, it will send random data to the wallet address provided. For now, we will delete the 'To' field from the transaction object. We'll clear the terminal and rerun the code. ### Building a Transaction Object ```python def main(): favorites_contract = w3.eth.contract(bytecode=compilation_details["bytecode"], abi=compilation_details["abi"]) # To deploy this, we must build a transaction print("Building the transaction...") transaction = favorites_contract.constructor().build_transaction() print(transaction) ``` ### Explanation We are building a transaction object that contains all the information we need to deploy a contract. The 'data' field inside the transaction object is where we will store the contract's bytecode. The 'To' field is left blank for deployment. The code shown above does not include the 'To' field. If we ran it in our terminal, the object would have a blank 'To' field as it is intended for a contract deployment. ### Summary When deploying a contract to the EVM, you need to build a transaction object with a blank 'To' field. The data field will contain the bytecode of the contract, allowing you to successfully deploy it to the EVM.
A practical guide to deploying a contract to the EVM - The video demonstrates the importance of having the "to" field blank in a transaction when deploying a contract to the EVM. It also explains why this field is important and how to update it to send data to a specific address.
Previous lesson
Previous
Next lesson
Next
Give us feedback
Course Overview
About the course
Python basics
Introduction to Web3.py
Introduction to Titanoboa
Introduction to Moccasin
How to create an ERC-20
How to test Python code and Vyper smart contract
How to deploy Vyper smart contracts on ZKsync using Moccasin
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
On-chain Data Analyst
$59,000 - $139,000 (avg. salary)
DeFi Developer
$75,000 - $200,000 (avg. salary)
Smart Contract Engineer
$100,000 - $150,000 (avg. salary)
Web3 developer
$60,000 - $150,000 (avg. salary)
Web3 Developer Relations
$85,000 - $125,000 (avg. salary)
Last updated on April 21, 2025
Duration: 2h 20min
Duration: 1h 51min
Duration: 58min
Duration: 2h 23min
Duration: 53min
Duration: 2h 24min
Duration: 28min
Duration: 1h 54min
Duration: 11min
Course Overview
About the course
Python basics
Introduction to Web3.py
Introduction to Titanoboa
Introduction to Moccasin
How to create an ERC-20
How to test Python code and Vyper smart contract
How to deploy Vyper smart contracts on ZKsync using Moccasin
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
On-chain Data Analyst
$59,000 - $139,000 (avg. salary)
DeFi Developer
$75,000 - $200,000 (avg. salary)
Smart Contract Engineer
$100,000 - $150,000 (avg. salary)
Web3 developer
$60,000 - $150,000 (avg. salary)
Web3 Developer Relations
$85,000 - $125,000 (avg. salary)
Last updated on April 21, 2025
Testimonials
Read what our students have to say about this course.
Chainlink
Chainlink
Gustavo Gonzalez
Solutions Engineer at OpenZeppelin
Francesco Andreoli
Lead Devrel at Metamask
Albert Hu
DeForm Founding Engineer
Radek
Senior Developer Advocate at Ceramic
Boidushya
WalletConnect
Idris
Developer Relations Engineer at Axelar