Skip to content

Commit

Permalink
ask a user switch a chain (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-korotya authored Oct 21, 2024
1 parent b6d043e commit 186a2e2
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 19 deletions.
4 changes: 2 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SUPPORTED_STATE_CONTRACTS="137=0xdc2A724E6bd60144Cde9DEC0A38a26C619d84B90,80001=0x134B1BE34911E39A8397ec6289782989729807a4,80002=0x1a4cC30f2aA0377b0c3bc9848766D90cb4404124"
SUPPORTED_RPC="137=<RPC_POLYGON_MAINNET>,80001=<RPC_POLYGON_MUMBAI>,80002=<RPC_MATIC_AMOY>"
SUPPORTED_STATE_CONTRACTS="80002=0x1a4cC30f2aA0377b0c3bc9848766D90cb4404124,21000=0x3C9acB2205Aa72A05F6D77d708b5Cf85FCa3a896"
SUPPORTED_RPC="80002=<RPC_URL_POLYGON_AMOY>,21000=https://rpc-mainnet.privado.id"
ISSUERS="<ISSUER_DID>"
EXTERNAL_HOST="<NGROK_URL>"
35 changes: 19 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ This is a demo frontend page that communicates with the [non-merklized on-chain

5. Fill the `.env` config file with the proper variables:
```bash
SUPPORTED_RPC="80002=<RPC_POLYGON_AMOY>"
SUPPORTED_STATE_CONTRACTS="80002=<AMOY_STATE_CONTRACT_ADDRESS>,21000=<PRIVADO_STATE_CONTRACT_ADDRESS>"
SUPPORTED_RPC="80002=<RPC_POLYGON_AMOY>,21000=<RPC_PRIVADO_MAIN>"
ISSUERS="<ISSUER_DID>"
EXTERNAL_HOST="<NGROK_URL>"
```
Expand All @@ -53,21 +54,23 @@ This is a demo frontend page that communicates with the [non-merklized on-chain
7. Open: http://localhost:3000

## How to verify the non zero balance claim:
1. Visit [https://verifier-demo.polygonid.me/](https://verifier-demo.polygonid.me/).
2. Choose `custom` from the drop-down menu.
3. Select the verifier based on your network:
- For polygon mumbai: `Mumbai`
- For polygon mainnet: `Mainnet`
- For polygon amoy: `Amoy`
4. Fill out the form:
- **Circuit Id**: Credential Atomic Query MTP
- **Url**: https://gist.githubusercontent.com/ilya-korotya/660496c859f8d31a7d2a92ca5e970967/raw/6b5fc14fe630c17bfa52e05e08fdc8394c5ea0ce/non-merklized-non-zero-balance.jsonld
- **Type**: Balance
- **Field**: balance
- **Operator**: All operators work for the claim
- **Value**: Set the value that you want to compare
5. Press submit.
6. Use the mobile application to verify.
1. Visit [https://tools.privado.id/query-builder](https://tools.privado.id/query-builder).
2. Build the next verification request:
```text
URL to JSON-LD Context: https://gist.githubusercontent.com/ilya-korotya/660496c859f8d31a7d2a92ca5e970967/raw/6b5fc14fe630c17bfa52e05e08fdc8394c5ea0ce/non-merklized-non-zero-balance.jsonld
Schema type: Balance
Attribute field: balance | address
Proof type: Merkle Tree Proof (MTP)
Circuit ID: any
Query type: Selective disclosure
```
3. Press: Create query
4. Scan the QR code with PrivadoID application

## License

Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/signin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const MyPage = () => {

<Grid xs={12} style={{marginTop: '-30px'}}>
<Typography textAlign="center" variant='h2'>
Use polygonID mobile app to scan this QR code
Use PrivadoID mobile app to scan this QR code
</Typography>
</Grid>
<Grid alignItems="center" xs={12} style={{marginTop: '30px'}}>
Expand Down
4 changes: 4 additions & 0 deletions client/src/services/onchainIssuer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,16 @@ export const issueCredential = async (contractAddress: string, userId: Id) => {
const from = accounts[0];
const onchainNonMerklizedIssuer = new web3.eth.Contract(contractABI, contractAddress);


const gasPrice = await web3.eth.getGasPrice();
const priorityGasPrice = gasPrice * BigInt(150) / BigInt(100);
const gasLimit = await onchainNonMerklizedIssuer.methods.issueCredential(userId.bigInt()).estimateGas({ from });
const increasedGasLimit = gasLimit * BigInt(140) / BigInt(100);

await onchainNonMerklizedIssuer.methods.issueCredential(userId.bigInt()).send({
from,
maxPriorityFeePerGas: priorityGasPrice.toString(),
gas: increasedGasLimit.toString(),
});
};

Expand Down

0 comments on commit 186a2e2

Please sign in to comment.