|
3 | 3 | [](https://github.com/hypercerts-org/protocol-periphery/actions/workflows/test.yml) |
4 | 4 | [](https://github.com/hypercerts-org/protocol-periphery/actions/workflows/slither.yaml) |
5 | 5 |
|
6 | | -## Implementation |
| 6 | +## Table of Contents |
7 | 7 |
|
8 | | -### BatchTransferFraction |
| 8 | +- [Hypercerts Periphery Contracts](#hypercerts-periphery-contracts) |
| 9 | + - [Table of Contents](#table-of-contents) |
| 10 | + - [BatchTransferFraction](#batchtransferfraction) |
| 11 | + - [Implementation](#implementation) |
| 12 | + - [Usage](#usage) |
| 13 | + - [Deployments](#deployments) |
| 14 | + |
| 15 | +## BatchTransferFraction |
| 16 | + |
| 17 | +### Implementation |
9 | 18 |
|
10 | 19 | ```mermaid |
11 | 20 | sequenceDiagram |
|
55 | 64 | } |
56 | 65 | ``` |
57 | 66 |
|
58 | | -## Deployments |
| 67 | +### Usage |
| 68 | + |
| 69 | +> [!important] |
| 70 | +> make sure you own the hypercerts. |
| 71 | +> |
| 72 | +> most of hypercerts have **CREATOR ONLY** [transfer restriction](https://github.com/hypercerts-org/hypercerts-protocol/blob/a606868b1f8d0502124428c45a985002170e6fca/contracts/src/protocol/interfaces/IHypercertToken.sol#L9-L19), so make sure you created the hypercerts as well. |
| 73 | +
|
| 74 | +1. Encode data with [ethers](https://docs.ethers.org/v5/api/utils/abi/coder) or [viem](https://viem.sh/docs/abi/encodeAbiParameters#encodeabiparameters). |
| 75 | + |
| 76 | + with ethers |
| 77 | + |
| 78 | + ```javascript |
| 79 | + import { ethers } from "ethers"; |
| 80 | + ... |
| 81 | + const recipients = ["0x123....", "0x456...."]; |
| 82 | + const fractionIds = [BigInt("23894....5301"), BigInt("23894....5302")]; |
| 83 | + |
| 84 | + const encodedData = ethers.AbiCoder.defaultAbiCoder().encode( |
| 85 | + [`tuple(address[], uint256[])`], |
| 86 | + [[recipients, fractionIds]] |
| 87 | + ); |
| 88 | + console.log('Encoded Data:', encodedData); |
| 89 | + // e.g. Encoded Data: 0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000006aa005386f53ba7b980c61e0d067cabc7602a620000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000c000000000000000000000000000000002 |
| 90 | + ``` |
| 91 | + |
| 92 | + with viem |
| 93 | + |
| 94 | + ```javascript |
| 95 | + import { encodeAbiParameters } from 'viem'; |
| 96 | + |
| 97 | + ... |
| 98 | + const recipients = ["0x123....", "0x456...."]; |
| 99 | + const fractionIds = [BigInt("23894....5301"), BigInt("23894....5302")]; |
| 100 | + const abiParams = [ |
| 101 | + { |
| 102 | + type: 'tuple', |
| 103 | + components: [{ type: 'address[]' }, { type: 'uint256[]' }], |
| 104 | + }, |
| 105 | + ]; |
| 106 | + const encodedData = encodeAbiParameters(abiParams, [ |
| 107 | + [recipients, fractionIds], |
| 108 | + ]); |
| 109 | + ``` |
| 110 | + |
| 111 | +2. In the HypercertsMinter contract on the chain where you want to execute batch transfer, call [setApprovalForAll (0xa22cb465)](https://optimistic.etherscan.io/address/0x822F17A9A5EeCFd66dBAFf7946a8071C265D1d07#writeProxyContract#F17) to approve the batchTransfer contract to send hypercerts. |
| 112 | + `operator == BatchTransfer contract address, approved == true` |
| 113 | + |
| 114 | +3. call batchTransfer function |
59 | 115 |
|
60 | | -### BatchTransferFraction |
| 116 | +### Deployments |
61 | 117 |
|
62 | 118 | | chain | chainId | address | |
63 | 119 | | ---------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------- | |
|
0 commit comments