Quick-start
When running the proof of concept, there are three features that need to be run simultaneously: the blockchain node, the real-world service provider, and the consumer.
Hardhat node
Clone the videre-contracts repository:
git clone https://github.com/windingtree/videre-contracts
Install the dependencies:
cd videre-contracts
yarn
Compile typechain artifacts:
yarn hardhat compile
Generate a mnemonic that you can use for test accounts. To do so, you can use this BIP39 generator. At the Mnemonic Code Converter:
- Select '24' words from the drop-down box.
- Press 'GENERATE'
- Copy the results of the
BIP39 Mnemonicfield to clipboard for the next step.
Configure the environment variables (.env), within the cloned repository's root directory to be similar to:
# network specific node uri : `"ETH_NODE_URI_" + networkName.toUpperCase()`
ETH_NODE_URI_MAINNET=https://eth-mainnet.alchemyapi.io/v2/<apiKey>
ETH_NODE_URI_SOKOL=https://sokol.poa.network
ETH_NODE_URI_GNOSIS=https://rpc.xdaichain.com
# generic node uri (if no specific found) :
ETH_NODE_URI=https://{{networkName}}.infura.io/v3/<apiKey>
# network specific mnemonic : `"MNEMONIC_ " + networkName.toUpperCase()`
# MNEMONIC_MAINNET=<mnemonic for mainnet>
# generic mnemonic (if no specific found):
MNEMONIC=<paste your mnemonic here with greater than/less than symbols>
# forking
# HARDHAT_FORK=gnosis
# coinmarketcap api key for gas report
COINMARKETCAP_API_KEY=
REPORT_GAS=true
# Etherscan API key for automatic verification of contracts
ETHERSCAN_API_KEY=
Now start the hardhat local blockchain for testing:
yarn hardhat node
When starting the hardhat local node, search through the console output for the address at which the StaysFacility contract was deployed. Example:
deploying "StaysFacility" (tx: 0x717c1eb6649abe7b92a0a2bead9b9f3b505da385980486283e5912ac90d699a9)...: deployed at 0x29b67856f9ca63dF5E688454B17F70Afd5071aa0 with 1758370 gas
In the above example, the StaysFacility contract was deployed to 0x29b67856f9ca63dF5E688454B17F70Afd5071aa0. Copy the address where it deployed on your local hardhat node as this will be used in subsequent configuration. For now though, your local blockchain node is running and ready to accept connections!
Server
Open another terminal window and clone the videre repository.
danger
Be sure not to clone videre into the videre-contracts directory.
git clone https://github.com/windingtree/videre
Install the dependencies:
yarn # installs lerna for monorepo
yarn lerna bootstrap # bootstrap packages
Change to the demo directory:
cd packages/demo
Generate the protobuf TypeScript:
yarn protoc --ts_out ./src/proto --proto_path ./src/proto ./src/proto/*
Copy over the typechain artifacts from the videre-contracts repo:
cp -pR path/to/videre-contracts/typechain .
Configure the environment varibles (.env) in the demo directory to be similar to:
MNEMONIC=<paste your mnemonic from before here with greater than/less than symbols>
SERVER_KEY_INDEX=1
CLIENT_KEY_INDEX=2
RPC_URL=http://127.0.0.1:8545
VIDERE_DAPP_NAME=videre-stays
VIDERE_DAPP_VERSION=1
REGISTRY_ADDRESS=<fill in with deployment address from videre-contracts>
FACILITY_NAME=Testing Facility
FACILITY_DATA_URI=http://testurl/
FACILITY_LOCATION=u173z
Now, you can start the server, and this will simulate being a service provider:
yarn ts-node ./src/server.ts
At this point, you should see the following activity:
- The
serverregisters a testfacility. - The
serverregisters 5spaces for thefacilityHashfrom (1). - The
serverconnects toWakuto monitor applicablecontent-topics.
This activity will be visible on the node as well as on the server.
Client
Open another terminal window and change into the demo package's directory:
cd path/to/demo
All the configuration for the client has already been done from the previous steps, so we can now run the client to make a query for accommodation:
yarn ts-node ./src/client.ts
At this point, you should see the following activity:
- The
clientconnects toWakuand asks (ping) for allfacilityHashin a certain shard. - The
serverresponds (pong)with it'sfacilityHashand some additional details. - The
clientverifies the pong from theserveragainst theStaysFacilitycontract. - The
client, knowing there is a legitimatefacility, asks for a stay with specific parameters (check-in, check-out, number of adults, number of children, number of spaces). - The
serverreceives the query from (4) and dispatches this to anauctioneerthat takes theaskparameters as input. It's then determined if thefacilitywants to make abidfor this business. - The
servercrafts a signed bid toclient. - The
clientverifies theserver's bid, and chooses one of the offers. - The
clientuses the bid'ssignatureto make the deal on-chain. - The
server, through event monitoring, can see that theclienthas made the deal. 🥳
tip
Sometimes there are connectivity issues to Waku from the client. Use Ctrl + C to terminate the client and start it again.