ZKsig JavaScript SDK
Library for interacting with the ZKsig digital signature contract in the following ways:
- Create agreements
- Sign agreements
- Get a list of agreements by address
- Get an agreement by address and index
- Get a list of signatures by address
- Get a signature by address and index
Contract
Interacting with the ZKsig smart contract depends on ethers.
- Read methods require an Ethers Provider.
- Write methods require an Ethers Signer
// Get a list of agreements for 0xa96bb1719fa7f78b8B2d3c24BBc79e52Ae9a3988
const provider = new providers.Web3Provider(window.ethereum);
const signer = provider.getSigner();
const contract = new ZKsigDigitalSignatureContract({
chainId: await signer.getChainId(),
signer,
});
const agreements = await contract.getAgreements({
page: 1,
perPage: 10,
});
// Get a user's profile
const provider = new providers.Web3Provider(window.ethereum);
const signer = provider.getSigner();
const contract = new ZKsigDigitalSignatureContract({
chainId: await signer.getChainId(),
signer,
});
const profile = await contract.getProfile();
PDF Agreements with ZKsigAgreement
The ZKsigAgreement
class helps interact with a PDF agreement in the
following ways:
- Add signature fields to a PDF
- Add the agreement to the blockchain
const agreement = new ZKsigAgreement();
await agreement.init(pdfBytes);
await agreement.addSignatureField({
page: 1, // page on which the signature should be
x: 10, // x coordinate on the PDF where the signature should start
y: 10, // y coordinate on the PDF where the signature should start
identifier: "employee", // signature field name used to group multiple fields with the same signer
});
await agreement.createOnChain(signer);