celocli
.
As of block height 31,056,500 (March 26, 2025, 3:00 AM UTC), Celo is no longer a standalone Layer 1 blockchainâit is now an Ethereum Layer 2!
Some documentation may be outdated as updates are in progress. If you encounter issues, please file a bug report.For the most up-to-date information, refer to our Celo L2 documentation.
Introduction to HSM
A cloud Hardware Security Module (HSM) provides a good balance between security and accessibility. A cloud HSM can manage a Celo private key and can be used seamlessly withcelocli
and contractkit
. Similar to a ledger device, a key in an HSM avoids the key from ever being sent over the network or stored on disk since the key can never leave the hardware boundary and all signing is performed within the HSM. To authenticate to the HSM, itâs recommended to create a service principal account that has been granted access to sign with the managed keys. A cloud HSM can be a great option for managing vote signer keys, since you may want these keys to be portable but also maintain good security practices.
Create an Azure subscription
If you donât have an Azure subscription already, you can create a free trial here that starts with $200 credit. You can view the pricing for Eliptic Curve Cryptography (ECC) HSM keys here.Deploy your Azure Key Vault
The Key Vault can store keys, secrets, and certificates. Permission can be specified to perform certain actions across the entire Key Vault (ex. key signing).- Search the marketplace for âKey Vaultâ
- Click Create and fill out the deployment information
- Ensure you select the Premium pricing tier for HSM support
- Enable soft-delete and purge protection to ensure your keys arenât accidentally deleted
Create your key
Next, weâll create the ECDSA key.- Navigate to your newly created Key Vault and click on the
Keys
section. - Click on âGenerate/Importâ
- Select âEC-HSMâ
- Select âSECP256K1â
Keys
section.
Create a Service Principal
A Service Principal (SP) is preferred over your personal account so that permission can be heavily restricted. In general, Service Principal accounts should be used for any automation or services that need to access Azure resources. Use the Cloud Shell to create the client credentials. Create a service principal and configure its access to Azure resources:celocli
or contractkit
.
Grant your Service Principal access to the key
In the Cloud Shell or Access Policies pane of the Key Vault, set the [GET, LIST, SIGN] permission for the new account.Connecting CeloCLI to KeyVault
Now that your environment variables are set, we just need to letcelocli
know that we want to use this Key Vault signer. We do this by passing in the flag --useAKV
and --azureVaultName
. Similar to --useLedger
, all CLI commands will use the HSM signer when --useAKV
is specified.
--useLedger
with --useAKV --azureVaultName $AZURE_VAULT_NAME
.
Connecting ContractKit to KeyVault
To leverage your HSM keys incontractkit
, first create an AzureHSMWallet
object and use it to create a ContractKit
object with newKitFromWeb3
. Note that AzureHSMWallet
expects AZURE_CLIENT_ID, AZURE_CLIENT_SECRET, and AZURE_TENANT_ID environment variables to be specified.