5/5
## Using an encrypted key in your moccasin script We've already encrypted a private key in our Moccasin project and have the following in our `mocassin.toml` file. ```toml [project] src = "src" [networks.anvil] url = "http://127.0.0.1:8545" save_to_db = false prompt_live = false ``` Now we can run this script. We can do ```bash mox run deploy --network anvil ``` We can also add the following to our command: ```bash mox run deploy --network anvil --account anvil1 ``` Moccasin knows that `anvil1` is one of the accounts that we have encrypted. When we hit enter we are prompted to enter our password for the keystore. We'll enter our password and you'll notice that it doesn't show our password. When we hit enter, it decrypts our key and sends the transactions. We can see that we have some transaction activity on the Anvil chain. This is very exciting!
We've already encrypted a private key in our Moccasin project and have the following in our mocassin.toml
file.
Now we can run this script. We can do
We can also add the following to our command:
Moccasin knows that anvil1
is one of the accounts that we have encrypted. When we hit enter we are prompted to enter our password for the keystore. We'll enter our password and you'll notice that it doesn't show our password. When we hit enter, it decrypts our key and sends the transactions. We can see that we have some transaction activity on the Anvil chain. This is very exciting!
A practical guide to using encrypted keys in your Moccasin script. This lesson demonstrates how to run a deploy script using Moccasin and how to securely interact with a local blockchain using an encrypted private key.
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 June 10, 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 June 10, 2025