10.1.0 • Published 1 year ago
@pactstech/pacts-viem v10.1.0
pacts-viem
pacts-viem is a simple tool set of helper functions to interact with pacts contracts.
Installation
Install @pactstech/pacts-viem
and its peer dependencies:
npm i viem@^2.9.0 abitype@^1.0.0 @pactstech/pacts-viem
Submitting an Order
import { createPublicClient, createWalletClient, custom, publicActions } from 'viem';
import { getProcessor, setupOrder, submitOrder } from '@pactstech/pacts-viem';
// viem client setup
const transport = custom(window.ethereum);
const publicClient = createPublicClient({ chain, transport });
const walletClient = createWalletClient({ chain, transport }).extend(publicActions);
// get processor instance
const address = '0x1234567890123456789012345678901234567890';
const processor = getProcessor({ address, client: walletClient });
// pacts order details
const orderId = 'dbdf2d90-b66e-4f39-bec3-388f76eadb42';
const price = 100n;
const shipping = 10n;
const metadata = { itemName: 'bicycle' };
// submits erc20 approvals, converts parameters
const args = await setupOrder({
publicClient,
walletClient,
processor,
orderId,
price,
shipping,
metadata
});
// submit order using args
const hash = await submitOrder({ processor, ...args });
const receipt = await publicClient.waitForTransactionReceipt({ hash });
if (receipt.status !== 'success') {
throw new Error('transaction failed');
}
console.log({ receipt });
10.1.0
1 year ago
10.0.1
1 year ago
10.0.0
1 year ago
9.0.0
1 year ago
8.0.0
1 year ago
7.0.1
1 year ago
7.0.0
1 year ago
6.0.0
1 year ago
5.0.0
1 year ago
4.0.1
1 year ago
4.0.0
1 year ago
3.0.0
1 year ago
2.3.0
1 year ago
2.2.0
1 year ago
2.1.0
1 year ago
2.0.4
1 year ago
2.0.3
1 year ago
2.0.2
1 year ago
2.0.1
1 year ago
2.0.0
1 year ago
1.3.0
1 year ago
1.2.5
1 year ago
1.2.4
1 year ago
1.2.3
1 year ago
1.2.2
1 year ago
1.2.1
1 year ago
1.2.0
1 year ago
1.1.5
1 year ago
1.1.4
1 year ago
1.1.3
1 year ago
1.1.2
1 year ago
1.1.1
1 year ago
1.1.0
1 year ago
1.0.2
1 year ago
1.0.1
1 year ago
1.0.0
1 year ago