Skip to content

Commit

Permalink
Merge pull request #18 from initc3/merge
Browse files Browse the repository at this point in the history
Merge oasis and secret network code
  • Loading branch information
njeans authored Aug 23, 2023
2 parents 0e91b9c + 7ba6747 commit f48ca48
Show file tree
Hide file tree
Showing 64 changed files with 10,305 additions and 324 deletions.
18 changes: 0 additions & 18 deletions .pause.github/actions/install-rust/README.md

This file was deleted.

12 changes: 0 additions & 12 deletions .pause.github/actions/install-rust/action.yml

This file was deleted.

38 changes: 0 additions & 38 deletions .pause.github/actions/install-rust/main.js

This file was deleted.

89 changes: 0 additions & 89 deletions .pause.github/workflows/Integration.yml

This file was deleted.

90 changes: 0 additions & 90 deletions .pause.github/workflows/Static.yml

This file was deleted.

82 changes: 5 additions & 77 deletions README.md
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.
11 changes: 11 additions & 0 deletions oasis/.gitignore
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

34 changes: 34 additions & 0 deletions oasis/README.md
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
```
Loading

0 comments on commit f48ca48

Please sign in to comment.