-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from initc3/merge
Merge oasis and secret network code
- Loading branch information
Showing
64 changed files
with
10,305 additions
and
324 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,80 +1,8 @@ | ||
# tee-offchain | ||
Code for the hackathon project at the IC3 2023 Summer camp. | ||
|
||
## Prerequisits | ||
## Oasis Sapphire Code | ||
See under the [oasis](./oasis) directory. | ||
|
||
- Rust and Cargo | ||
- Docker | ||
- Node and NPM | ||
- [Secretcli](https://docs.scrt.network/secret-network-documentation/development/getting-started/setting-up-your-environment#install-secretcli) | ||
|
||
## Build contract | ||
|
||
Build and optmize the contract with: | ||
``` | ||
make build | ||
``` | ||
This will output a `contract.wasm.gz` file ready to be deployed. | ||
|
||
## Unit tests | ||
``` | ||
cargo test | ||
``` | ||
|
||
## Build and deploy the contract on a local net | ||
Launch the local net in a seperate terminal | ||
``` | ||
make start-server | ||
``` | ||
|
||
Setup test accounts | ||
``` | ||
./setup_accounts.sh | ||
``` | ||
|
||
|
||
Run worker script | ||
``` | ||
cd worker/js | ||
npm install | ||
npm run worker | ||
``` | ||
|
||
Example Output | ||
``` | ||
> [email protected] worker /home/root/tee-offchain/worker/js | ||
> node src/worker.js | ||
Uploading contract | ||
codeId: 1 | ||
Contract hash: 69c324044c4362862657d9a48368bae6a75af9a3bce1f8831dd148c4e7cb1c2b | ||
contractAddress=secret1fse00hs0clpgkaz83rkc0rtglr04uqpf6ctv5y | ||
[user1a57rwy] Sending deposit 100 uscrt | ||
[user1tah2fd] Sending deposit 100 uscrt | ||
[user1a57rwy] viewingKey api_key_8DrgKPL1S4ksEOBOaqE2B06pkyKrxSeyLw99UBgxX5c= | ||
[user1tah2fd] viewingKey api_key_8LioLjry849VFUVY+3wD5tNBkVnotyOiNM2JM1546+w= | ||
[user1a57rwy] balance=0 | ||
[user1tah2fd] balance=0 | ||
*****************starting worker1ld9a that processes 2 transactions every 5000 ms***************** | ||
[worker1ld9a] Sending commit | ||
[worker1ld9a] Sending write checkpoint | ||
[worker1ld9a] Sending commit | ||
[worker1ld9a] Sending write checkpoint | ||
[user1a57rwy] balance=100 | ||
[user1tah2fd] balance=100 | ||
[user1a57rwy] Sending transfer 50 to user1tah2fd | ||
[worker1ld9a] Sending commit | ||
[worker1ld9a] Sending write checkpoint | ||
[user1a57rwy] balance=50 | ||
[user1tah2fd] balance=150 | ||
[user1a57rwy] Sending withdraw 50 uscrt | ||
[user1tah2fd] Sending withdraw 50 uscrt | ||
[worker1ld9a] Sending commit | ||
[worker1ld9a] Sending write checkpoint | ||
[worker1ld9a] Sending commit | ||
[worker1ld9a] Sending write checkpoint | ||
[user1a57rwy] balance=0 | ||
[user1tah2fd] balance=100 | ||
^C | ||
``` | ||
## SecretNetwork Code | ||
See under the [secretnetwork](./secretnetwork) directory. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
node_modules | ||
.env | ||
coverage | ||
coverage.json | ||
typechain | ||
typechain-types | ||
|
||
# Hardhat files | ||
cache | ||
artifacts | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Off-chain private tokens | ||
An implementation of off-chain private tokens in Oasis Sapphire. | ||
|
||
Requirements: | ||
* Node | ||
* Docker | ||
|
||
## Setup | ||
First, install all required packages with `npm`: | ||
``` | ||
npm install | ||
``` | ||
|
||
### Create a dev network: | ||
``` | ||
docker run -it -p8545:8545 -p8546:8546 ghcr.io/oasisprotocol/sapphire-dev -to "0x72A6CF1837105827077250171974056B40377488" | ||
``` | ||
|
||
### Run test cases | ||
```shell | ||
npx hardhat test --network dev | ||
``` | ||
|
||
Fund two addresses whose private keys are in `PRIVATE_KEY` and `PRIVATE_KEY2`. | ||
|
||
Test the deployment of the off-chain hash machine on the public Sapphire testnet: | ||
``` | ||
PRIVATE_KEY=<funded private key> npx hardhat run scripts/deploy.ts --network sapphire_testnet | ||
``` | ||
|
||
Run the veiled token demo on the public testnet: | ||
``` | ||
PRIVATE_KEY=$PRIVATE_KEY PRIVATE_KEY2=$PRIVATE_KEY2 npx hardhat run scripts/runVeiledToken.ts --network sapphire_testnet | ||
``` |
Oops, something went wrong.