Send private transactions¶
This tutorial shows you how to send private transactions.
Prerequisites¶
- Privacy-enabled network running as configured in tutorial. The nodes must be running.
Steps¶
1. Create private contract¶
In the Node-0
directory, copy and paste the following to a file called private-contract.js
. On the highlighted line, replace the placeholder for privateFor
with the base64 content of the tessera1.pub
key file. For example, 1oRj9qpgnNhr/ZUggeMXnXsWMuVgedS6gfimpEVt+EQ=
.
Important
Don’t include the sender’s node in privateFor
. To create a private contract visible to the sender’s node only, use this format: privateFor: []
.
2. Create account¶
In the Node-0
directory, create an account.
3. Unlock account¶
Accounts are locked by default and must be unlocked before sending the transaction. Use the geth
console to display and unlock the account.
Display the accounts.
Unlock the account using the account key displayed by eth.accounts
.
Type in the account password when prompted.
Tip
By default, accounts remain unlocked for 5 minutes. After 5 minutes, the account is relocked.
4. Send private transaction¶
Important
All participants listed in privateFor
must have their private transaction managers running when the private transaction is sent. Otherwise, the transaction doesn’t propagate and an error is returned.
In the geth
console, run loadScript
to deploy the contract and send a private transaction from node 0 to node 1.
The GoQuorum logs for node 0 indicate the private transaction was sent.
DEBUG[12-08|13:53:09.380] sending private tx txnType=3 data=606060…00002a privatefrom= privatefor="[yrrHrbeaXzZCYJ4DPXrunvms1/jy5zDvoH5KnNyW4VE=]" privacyFlag=0
DEBUG[12-08|13:53:09.381] Simulated Execution EVM call finished runtime=594ns
TRACE[12-08|13:53:09.381] after simulation affectedCATxHashes=map[] merkleRoot=000000…000000 privacyFlag=0 error=nil
INFO [12-08|13:53:09.629] sent private signed tx data=606060…00002a hash=f93744…407111 privatefrom= privatefor="[yrrHrbeaXzZCYJ4DPXrunvms1/jy5zDvoH5KnNyW4VE=]" affectedCATxHashes=map[] merkleroot=000000…000000 privacyflag=0
DEBUG[12-08|13:53:09.629] Handle Private Transaction finished took=249.112348ms
INFO [12-08|13:53:09.630] Private transaction signing with QuorumPrivateTxSigner
The Tessera logs indicate the transaction payload was distributed and received.
2020-12-08 13:53:09.390 [qtp1487391298-33] INFO c.q.tessera.q2t.TransactionResource - Enter Request : POST : /send
2020-12-08 13:53:09.525 [pool-5-thread-1] INFO c.q.tessera.q2t.RestPayloadPublisher - Publishing message to http://localhost:9003/
2020-12-08 13:53:09.616 [pool-5-thread-1] INFO c.q.tessera.q2t.RestPayloadPublisher - Published to http://localhost:9003/
2020-12-08 13:53:09.622 [qtp1487391298-33] INFO c.q.tessera.q2t.TransactionResource - Exit Request : POST : /send
2020-12-08 13:53:09.622 [qtp1487391298-33] INFO c.q.tessera.q2t.TransactionResource - Response for send : 201 Created
2020-12-08 13:53:09.548 [qtp1564775175-89] INFO c.q.tessera.p2p.TransactionResource - Enter Request : POST : /push
2020-12-08 13:53:09.614 [qtp1564775175-89] INFO c.q.t.t.TransactionManagerImpl - Stored payload with hash +TdE/ZNMX0IrqLSwLh6szKS4rxCuDB9NbpdLf7yXjfwS0ATYsnpSkCCJ+SSzh0D19CT4RZGzAiiFldF9pkBxEQ==
2020-12-08 13:53:09.615 [qtp1564775175-89] INFO c.q.tessera.p2p.TransactionResource - Exit Request : POST : /push
2020-12-08 13:53:09.615 [qtp1564775175-89] INFO c.q.tessera.p2p.TransactionResource - Response for push : 201 Created
2020-12-08 13:53:12.024 [qtp1527084496-36] INFO c.q.tessera.q2t.TransactionResource - Enter Request : GET : /transaction/+TdE/ZNMX0IrqLSwLh6szKS4rxCuDB9NbpdLf7yXjfwS0ATYsnpSkCCJ+SSzh0D19CT4RZGzAiiFldF9pkBxEQ==
2020-12-08 13:53:12.047 [qtp1527084496-36] INFO c.q.t.t.TransactionManagerImpl - Lookup transaction +TdE/ZNMX0IrqLSwLh6szKS4rxCuDB9NbpdLf7yXjfwS0ATYsnpSkCCJ+SSzh0D19CT4RZGzAiiFldF9pkBxEQ==
2020-12-08 13:53:12.088 [qtp1527084496-36] INFO c.q.tessera.q2t.TransactionResource - Exit Request : GET : /transaction/+TdE/ZNMX0IrqLSwLh6szKS4rxCuDB9NbpdLf7yXjfwS0ATYsnpSkCCJ+SSzh0D19CT4RZGzAiiFldF9pkBxEQ==
2020-12-08 13:53:12.088 [qtp1527084496-36] INFO c.q.tessera.q2t.TransactionResource - Response for transaction/+TdE/ZNMX0IrqLSwLh6szKS4rxCuDB9NbpdLf7yXjfwS0ATYsnpSkCCJ+SSzh0D19CT4RZGzAiiFldF9pkBxEQ== : 200 OK