Skip to content

Commit

Permalink
Update for web3c 2.0 (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
peterjgilbert committed Feb 20, 2019
1 parent db0c2d0 commit 6012f9a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ Once installed, you can use truffle commands like you would any other truffle pr
- `truffle migrate --network oasis`
- `truffle test --network oasis`.

To mark your contract confidential, prefix your contract's filename with either `confidential_` or `confidential-*`, for example, `confidential_MyContract.sol` for Solidity or `confidential-my-contract-crate` for Rust. When your contract compiles, with one of the above truffle commands, its bytecode will be prepended with `b'\0enc'`. On deploy, this bytecode prefix will notify the Oasis runtime that the contract is to be run inside a secure enclave, at which point one should use [web3c.js](https://github.com/oasislabs/web3c.js) to communicate with the contract through an encrypted channel.
To mark your contract confidential, prefix your contract's filename with either `confidential_` or `confidential-*`, for example, `confidential_MyContract.sol` for Solidity or `confidential-my-contract-crate` for Rust. When your contract compiles with one of the above truffle commands, its bytecode will be prepended with a header indicating that it should be deployed as a confidential contract. On deploy, the header indicates to the Oasis runtime that the contract is to be run inside a secure enclave, at which point one should use [web3c.js](https://github.com/oasislabs/web3c.js) to communicate with the contract through an encrypted channel.

To do this, simply retrieve the contract's deploy address from the artifact, and instantiate a web3c.js Contract object with it. For example,

```
const MyContract = artifacts.require("MyContract");
const contractInstance = web3c.confidential.Contract(MyContract.abi, MyContract.address, { ... });
const contractInstance = web3c.oasis.Contract(MyContract.abi, MyContract.address, { ... });
```

For more details, see the [truffle](https://truffleframework.com/docs/truffle/overview) and [web3c.js](https://github.com/oasislabs/web3c.js) documentation.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
},
"devDependencies": {
"truffle-hdwallet-provider": "^1.0.0-web3one.0",
"oasis-compile": "^1.0.1",
"oasis-compile": "^2.0.0-beta1",
"web3-provider-engine": "^14.1.0"
},
"keywords": [
Expand All @@ -19,6 +19,6 @@
"url": "git+https://github.com/oasislabs/oasis-box.git"
},
"dependencies": {
"web3c": "^1.0.0"
"web3c": "^2.0.0-beta1"
}
}
4 changes: 2 additions & 2 deletions test/test-counters.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ contract("Counter Contracts", (accounts) => {
const contracts = [
new web3c.eth.Contract(Counter.abi, Counter.address, options),
new web3c.eth.Contract(NestedCounter.abi, NestedCounter.address, options),
new web3c.confidential.Contract(ConfidentialCounter.abi, ConfidentialCounter.address, options),
new web3c.oasis.Contract(ConfidentialCounter.abi, ConfidentialCounter.address, options),
new web3c.eth.Contract(WasmCounter.abi, WasmCounter.address, options),
new web3c.eth.Contract(NestedWasmCounter.abi, NestedWasmCounter.address, options),
new web3c.confidential.Contract(ConfidentialWasmCounter.abi, ConfidentialWasmCounter.address, options)
new web3c.oasis.Contract(ConfidentialWasmCounter.abi, ConfidentialWasmCounter.address, options)
];

contracts.forEach((contract) => {
Expand Down

0 comments on commit 6012f9a

Please sign in to comment.