evt-toolchain v0.0.2
evt-toolchain
Summary
In this toolchain, you can use some simple shell command line to deploy contract, create EVT, call EVT Encryption functions, call EVT Variable functions. etc.
Development with EVT
Prerequisites
- Node.js installed on your local machine.
- Get RPC Endpoint and ChainId which you want to try.
- Own an Address and PrivateKey
Get source code and Install
```bash
# install evt-toolchain
npm install evt-toolchain -D
# create .env file in your project root
source .env
# set new CHAIN_ID, RPC_URL, PRIVATE_KEY in .env file
```
Use EVT and EVTA
- Deploy Contract
# ex.: npx evtc deploy ./templete.sol contractName npx evtc deploy contract_path contract_name
Create
EVT
# mint EVT npx evtc evt call mintEVT # you can get EVT_ADDRESS and EVTA_ADDRESS in log file # copy contract addresses to .env file # the token will be owned by your address
EVTA
# mint EVTA. quantity: the amount you want to mint npx evtc evt call mintEVTA quantity # the tokens will be owned by your address
By run Deploy and Mint, you can check your contract and EVT in blockchain explorar.
If you use Newchain testnet configuration, you can see in Newton Testnet Explorar with EVT_ADDRESS, EVTA_ADDRESS or ACCOUNT.
Use EVT Encryption
We provide an open source project NewKeeper
to combine with EVT Encryption.
Run NewKeeper
# pull newkeeper-dev v0.1 docker pull pschy/newkeeper-dev # run newkeeper with a PORT docker run -it -d -p `PORT`:8000 --name newkeeper pschy/newkeeper-dev # check status and get CONTAINER ID docker ps # show logs docker logs -f `CONTAINER ID` # set NEWKEEPER url in .env file
Deploy Contract
# deploy contract npx evtc encryption deploy # get TOKEN_ADDRESS and CONTRACT_ADDRESS, set in .env file
Call Functions
# call contract functions with params npx evtc encryption call functions params
Use the shell common line to call Below functions. you can get returns in commander
Functions
- mint_EVT()
desc
mint a Token for encryption key register permission.
mint_token()
desc
mint a new EVT
get_balance()
desc
check address token balance, the permission for Key register
returns
balance
generator()
desc
call Newkeeper to generator KeyId
returns
peerPrivateKey, keyId, privateKey, peer, prime, peerPublicKey
register_encrypted_key(params)
desc
Use a keyId to encrypted a Token.
params
tokenId, keyId
add_permission(params)
desc
Add permission to an Address with a keyId
params
tokenId, keyId, licensee(an address)
has_permission(params)
desc
Check the permission
params
tokenId, keyId, licensee(an address)
returns
result
register(params)
desc
Bind keyId, tokenId, Contract in NewKeeper
params
tokenId, KeyId, peerPrivateKey, privateKey (you can get these from generator function)
get_key(params)
desc
Get PrivateKey
params prime, peerSwapKey, KeyId
- mint_EVT()
You can also run a commond line to test EVT encryption:
npx evtc encryption test
It will deploy contracts, mint token and evt, generate key with Newkeeper etc.
Use EVT Variable
Deploy Contract
# deploy contract npx evtc variable deploy # get TOKEN_ADDRESS and CONTRACT_ADDRESS, set in .env file
Call functions
# Mint evt npx evtc variable call mint # Add a Property. like: height, with, age. etc. npx evtc variable call addProperty propertyName # Set Property to a EVT # ex.: npx evtc variable call setProperty 0 age 30 npx evtc variable call setProperty tokenId propertyName propertyValue # Get Property # ex.: npx evtc variable call getProperty 0 age npx evtc variable call getProperty tokenId propertyName