Market Creation
Once you have the prover image and ivs image, you can create the market. Market creation can be done using two methods:
- SDK (preferred)
- Explorer UI
Note: You must as also chose the following parameters from create the marketplace based the security parameters of your choice.
- Market metadata: Details related to the market but are not enforced.
- Wrapper address: Address of verifier wrapper address. Mandatory field.
- Slashing penalty: Slashing amount for market. Mandatory field.
2. Using the SDK
To create market requests using SDK, follow these steps:
2.1. Set Up Environment
Create a new folder and navigate to it in a terminal. Initialize a Node.js project using the following command:
npm init
Node.js project is set up, navigate to it in the terminal and run the following command to install the necessary packages:
npm i kalypso-sdk ethers ts-node bignumber.js
In the project folder, create two new folders with files as follows:
contracts
|- arbSepolia.json
Keys
|- key.json
- arbSepolia.json: contains the address of all the contracts needed in the scripts.
- key.json: contains the address for RPC and private keys.
Note: Make sure the addresses are the most recent ones.
2.2 Create a market tranzaction
import { ethers } from "ethers";
import { KalypsoSdk } from "kalypso-sdk";
import * as fs from "fs";
const kalypsoContracts = JSON.parse(fs.readFileSync("./contracts/arbSepolia.json", "utf-8"));
const keys = JSON.parse(fs.readFileSync("./keys/key.json", "utf-8"));
async function main(): Promise<string> {
const provider = new ethers.JsonRpcProvider(keys.rpc);
const wallet = new ethers.Wallet(keys.private_key, provider);
const kalypso = new KalypsoSdk(wallet, kalypsoContracts);
const marketSetupData = {
zkAppName: "Application Name",
proverCode: "link to the prover code",
verifierCode: "link to the verifier code",
proverOysterImage: "link to oyster image url",
setupCeremonyData: [""],
inputOuputVerifierUrl: "optional",
};
const wrapperAddress = "address of your wrapper contract";
const slashingPenalty = "1000000000000000000";
const marketBytes = Buffer.from(JSON.stringify(marketSetupData), "utf-8");
// if you don't know pcrs, fetch them programatically.
const proverImagePcrs = KalypsoSdk.getRlpedPcrsFromAttestation(proverAttestationData.attestation_document);
const tx = await kalypso.MarketPlace().createNewMarket(marketBytes, wrapperAddress, slashingPenalty, proverImagePcrs, proverImagePcrs)
await tx.wait();
const receiptHash = tx.hash;
console.log("Receipt hash", receiptHash);
return "Done"
}
main().then(console.log).then(console.log)
npm run ts-node createMarket.ts