https://github.com/newtonproject/evt-toolchain
https://github.com/newtonproject/evt-toolchain
Last synced: 7 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/newtonproject/evt-toolchain
- Owner: newtonproject
- License: gpl-3.0
- Created: 2022-09-05T03:24:03.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2022-12-05T13:20:03.000Z (over 2 years ago)
- Last Synced: 2024-11-20T01:05:52.196Z (7 months ago)
- Language: Solidity
- Size: 101 KB
- Stars: 1
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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
1. Node.js installed on your local machine.
2. Get RPC Endpoint and ChainId which you want to try.
3. Own an Address and PrivateKey#### **Newton Mainnet:**
RPC:
https://global.rpc.mainnet.newtonproject.orgChainId:
1012Block Explorer:
https://explorer.newtonproject.org#### **Newton Testnet:**
RPC:
https://rpc1.newchain.newtonproject.orgChainId:
1007Block Explorer:
https://explorer.testnet.newtonproject.org
http://e.testnet.diynova.com
### Get source code and Install
```bash
# install evt-toolchain
npm install @newton-protocol/evt-toolchain# create .env file in your project root
touch .env
# set new CHAIN_ID, RPC_URL, PRIVATE_KEY in .env file
```### Use EVT and EVTA
1. Deploy Contract
```bash
npx evtc evt deploy
```
2. Create
1. EVT
```bash
# 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
```
2. EVTA
```bash
# mint EVTA. quantity: the amount you want to mint
npx evtc evt call mintEVTA
# 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](http://e.testnet.diynova.com/) with EVT_ADDRESS, EVTA_ADDRESS or ACCOUNT.
### Use EVT Encryption
We provide an open source project [`NewKeeper`](https://github.com/newkeeper-core/newkeeper) to combine with EVT Encryption.
You need some knowledge of Deffie-Hellman key exchange algorithm(DH algorithm) and AES encryption to understand newkeeper.
1. Run NewKeeper
```bash
# pull newkeeper-dev v0.3, version: 0.3
docker pull pschy/newkeeper-dev:# run newkeeper with a PORT(You need to change `PORT` to your local PORT), for example, `PORT`= 80, version: 0.3
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, for example: NEWKEEPER="http://127.0.0.1:`PORT`/"(`PORT`: Your Local Port)
```2. Deploy Contract
```bash# deploy contract
npx evtc encryption deploy
# get TOKEN_ADDRESS and CONTRACT_ADDRESS, set in .env file
```
3. Call Functions
```bash
# call contract functions with params
npx evtc encryption call
```
Use the shell common line to call Below functions. you can get returns in commander#### **Functions**
- mint_token()
- desc
mint a Token for encryption key register permission.
- mint_EVT()
- descmint a new EVT
- get_balance()
- desccheck address token balance, the permission for Key register
- returnsbalance
- generator()
- desccall Newkeeper to generate KeyId
- returnspeerPrivateKey, keyId, privateKey, peer, prime, peerPublicKey
- register_encrypted_key(params)
- descUse a keyId to encrypted a Token.
- paramstokenId, keyId
- add_permission(params)
- descAdd permission to an Address with a keyId
- paramstokenId, keyId, licensee(an address)
- has_permission(params)
- descCheck the permission
- paramstokenId, keyId, licensee(an address)
- returnsresult
- register(params)
- descBind keyId, tokenId, Contract in NewKeeper
- paramstokenId, KeyId, peerPrivateKey, privateKey (you can get these from generator function)
- get_key(params)
- descGet PrivateKey
- paramsprime, peerSwapKey, KeyId
You can also run a commond line to test EVT encryption:
```bash
npx evtc encryption test
```
It will deploy contracts, mint token and evt, generate key with Newkeeper etc.### Use EVT Variable
1. Deploy Contract
```bash# deploy contract
npx evtc variable deploy
# get TOKEN_ADDRESS and CONTRACT_ADDRESS, set in .env file
```
2. Call functions```bash
# Mint evt
npx evtc variable call mint# Add a Property. like: height, with, age. etc.
npx evtc variable call addProperty# Set Property to a EVT
# ex.: npx evtc variable call setProperty 0 age 30
npx evtc variable call setProperty# Get Property
# ex.: npx evtc variable call getProperty 0 age
npx evtc variable call getProperty
```## Reference
- https://www.newtonproject.org/en/evt/
- https://neps.newtonproject.org/neps/nep-53/
- https://github.com/newtonproject/evt-lib
- https://neps.newtonproject.org/neps/nep-61/