Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re org quickstart contracts #268

Merged
merged 3 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 70 additions & 4 deletions docs/tutorials/quorum-dev-quickstart/using-the-quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,72 @@ The result indicates the highest block number synchronized on this node.

Here the hexadecimal value `0x2a` translates to decimal as `42`, the number of blocks received by the node so far, about two minutes after the new network started.

## Public transactions

This example uses the [web3.js](https://www.npmjs.com/package/web3) library to make the API calls, using the `rpcnode`
accessed on `http://localhost:8545`.

Navigate to the `smart_contracts` directory and deploy the public transaction:

```bash
cd smart_contracts
npm install
node scripts/public/public_tx.js
# or via ethers
node scripts/public/public_tx_ethers.js
```

This deploys the contract and sends an arbitrary value (`47`) from `Member1` to `Member3`. The script then performs:

1. A read operation on the contract using the `get` function and the contract's ABI, at the specified address.
1. A write operation using the `set` function and the contract's ABI, at the address and sets the value to `123`.
1. A read operation on all events emitted.

The script output is as follows:

```bash
{
address: '0x03e034D03b04A348143F2C25884e1E4946fa6196',
privateKey: '0xca3a6f8b83ed5876201605ae8507490d0a0205c0748e6376ed9661c9fecb98d7',
signTransaction: [Function: signTransaction],
sign: [Function: sign],
encrypt: [Function: encrypt]
}
create and sign the txn
sending the txn
tx transactionHash: 0x6e62d7db1ec001a127130da6434358f44af0f6adee0466902e3eb8160f31c950
tx contractAddress: 0x1fBDd454d617E21c7121161b154B764Dc5844fc9
Contract deployed at address: 0x1fBDd454d617E21c7121161b154B764Dc5844fc9
Use the smart contracts 'get' function to read the contract's constructor initialized value ..
Obtained value at deployed contract is: 47
Use the smart contracts 'set' function to update that value to 123 ..
Set value on contract at : 0xdcaf84bbdd35811820dbb13453e1532d5cd3e3ef718e12a49878de67948e0b9b
Verify the updated value that was set ..
Obtained value at deployed contract is: 123
Obtained all value events from deployed contract : [47,123]
```

We also have a second example that shows how to transfer ETH between accounts. Navigate to the `smart_contracts` directory
and deploy the `eth_tx` transaction:

```bash
cd smart_contracts
npm install
node scripts/public/eth_tx.js
```

The output is as follows:

```bash
Account A has balance of: 90000
Account B has balance of: 0
create and sign the txn
sending the txn
tx transactionHash: 0x8b9d247900f2b50a8dded3c0d73ee29f04487a268714ec4ebddf268e73080f98
Account A has an updated balance of: 89999.999999999999999744
Account B has an updated balance of: 0.000000000000000256
```

## Private transactions

This example uses the [web3.js](https://www.npmjs.com/package/web3) library to make the API calls, creating three member nodes pairs (a GoQuorum node which has a corresponding Tessera node for privacy) that can be accessed using APIs on the following ports:
Expand All @@ -240,12 +306,12 @@ Member3Quorum RPC: http://localhost:20004
Member1Tessera: http://localhost:9083
```

Navigate to the `smart_contracts/privacy` directory and deploy the private transaction:
Navigate to the `smart_contracts` directory and deploy the private transaction:

```bash
cd smart_contracts/privacy
cd smart_contracts
npm install
node scripts/private_tx.js
node scripts/private/private_tx.js
```

This deploys the contract and sends an arbitrary value (`47`) from `Member1` to `Member3`.
Expand All @@ -257,7 +323,7 @@ It then performs a write operation using the `set` function and the contract's A
Lastly, it performs a read operation on all three members to verify that this is private between `Member1` and `Member3` only, and you should see that only `Member1` and `Member3` return the result of `123`, and `Member2` has an undefined value.

```bash
node scripts/private_tx.js
node scripts/private/private_tx.js
The transaction hash is: 0x4d796b2ccac109fc54006105df44c519341696fa88e004ce5c614239cb9f92a2
Address of transaction: 0x695Baaf717370fcBb42aB45CD83C531C27D79eF1
Use the smart contracts 'get' function to read the contract's constructor initialized value ..
Expand Down
1 change: 1 addition & 0 deletions project-words.txt
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ roadmap
rocketvalidator
rootca
rpcapi
rpcnode
rpcprefix
rtcts
rtlcss
Expand Down