- Create an account that has ECDSA keys using the Javascript SDK
- Compile a contract using Truffle
- Deploy the smart contract to Hedera network through the JSON RPC Relay
Prerequisites
- Get a Hedera testnet account
- This Codesandbox is already setup for you to try this example
- Fork the sandbox
- Remember to provide your testnet account credentials for the operator in the .env file
- Open a new terminal and run:
- npm install -g truffle (this installation may take a few minutes)
- node create-account.js
- Get the example code from GitHub
Table of Contents
Create an Account that Has ECDSA Keys
Hedera supports two popular types of signature algorithms, ED25519 and ECDSA. Both are used in many blockchain platforms, including Bitcoin and Ethereum. Currently, the JSON RPC Relay only supports Hedera accounts with an alias set (i.e. public address) based on its ECDSA public key. To deploy a smart contract using Truffle, we first have to create a new account that meets these criteria. The main() function in create-account.js helps us do just that. In case you’re interested in more details about auto account creation and alias, check out the documentation and HIP-32.
Helper Functions
The functions autoCreateAccountFcn() and mirrorQueryFcn() perform the auto account creation and mirror query, respectively.Compile a Smart Contract Using Truffle
Now it’s time to compile SimpleStorage, which is a basic smart contract that allows anyone to set and get data.
Deploy the Smart Contract to Hedera Using Truffle
Finally, deploy the contract on Hedera through the JSON RPC Relay. Be sure to configure the following parameters in your .env file to be able to deploy to the Hedera testnet with Truffle.
Mirror node queries
Mirror node queries