@tokenops/sdk 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +207 -0
- package/CONTRIBUTING.md +113 -0
- package/LICENSE +32 -0
- package/README.md +677 -0
- package/SECURITY.md +59 -0
- package/dist/chunk-52TC6BF7.js +2755 -0
- package/dist/chunk-56UI7LUR.cjs +516 -0
- package/dist/chunk-5SA2HF2W.cjs +1635 -0
- package/dist/chunk-5SGMJADP.cjs +139 -0
- package/dist/chunk-62DF53UQ.cjs +749 -0
- package/dist/chunk-66IHPTOK.cjs +20 -0
- package/dist/chunk-6ECAHP5O.cjs +1496 -0
- package/dist/chunk-72YGZEQE.js +742 -0
- package/dist/chunk-7VELUOMI.js +35 -0
- package/dist/chunk-BE2AIZ3K.js +23 -0
- package/dist/chunk-CMRETRZO.js +46 -0
- package/dist/chunk-COPFW5Z4.js +82 -0
- package/dist/chunk-CQIPRNS7.cjs +25 -0
- package/dist/chunk-ECT3NL2L.js +124 -0
- package/dist/chunk-FWHYQZ5E.cjs +37 -0
- package/dist/chunk-FYQ2UW4T.js +37 -0
- package/dist/chunk-HGXNRR25.js +105 -0
- package/dist/chunk-HTOMTEA3.cjs +3406 -0
- package/dist/chunk-ITQ7WKVC.cjs +101 -0
- package/dist/chunk-IVE3QEGD.js +478 -0
- package/dist/chunk-JFLEEXKP.js +325 -0
- package/dist/chunk-JFR5J4FL.cjs +128 -0
- package/dist/chunk-K6MFFDBJ.cjs +109 -0
- package/dist/chunk-KWFFIJYX.js +11 -0
- package/dist/chunk-NS44KBV5.cjs +89 -0
- package/dist/chunk-OLDGMKW2.cjs +93 -0
- package/dist/chunk-Q2GP5UDC.js +29 -0
- package/dist/chunk-Q7ARQSUH.cjs +42 -0
- package/dist/chunk-QCA7O2Q5.cjs +49 -0
- package/dist/chunk-QIHZVLIK.js +3388 -0
- package/dist/chunk-SUOG3BQS.cjs +2772 -0
- package/dist/chunk-T5LVV3KY.cjs +44 -0
- package/dist/chunk-UOG4PJL5.js +1488 -0
- package/dist/chunk-VDXVNZCO.cjs +329 -0
- package/dist/chunk-VJKZWYYJ.cjs +32 -0
- package/dist/chunk-WRCUDSUJ.js +96 -0
- package/dist/chunk-XSNLAS5M.js +135 -0
- package/dist/chunk-XXXDQSHE.js +1628 -0
- package/dist/chunk-ZHFLRKFY.js +41 -0
- package/dist/chunk-ZXCOJY2Z.js +87 -0
- package/dist/core/addresses.d.ts +59 -0
- package/dist/core/brands.d.ts +87 -0
- package/dist/core/chains.d.ts +102 -0
- package/dist/core/errors.d.ts +687 -0
- package/dist/core/index.d.ts +7 -0
- package/dist/core/normalise.d.ts +27 -0
- package/dist/core/preflight.d.ts +25 -0
- package/dist/core/revert-mapper.d.ts +74 -0
- package/dist/core/telemetry.d.ts +50 -0
- package/dist/core/types.d.ts +10 -0
- package/dist/core/version.d.ts +15 -0
- package/dist/core/zama-error-mapper.d.ts +27 -0
- package/dist/fhe/acl.d.ts +73 -0
- package/dist/fhe/erc7984-abi.d.ts +53 -0
- package/dist/fhe/index.cjs +599 -0
- package/dist/fhe/index.d.cts +11 -0
- package/dist/fhe/index.d.ts +11 -0
- package/dist/fhe/index.js +394 -0
- package/dist/fhe/mock-encryptor.d.ts +90 -0
- package/dist/fhe/mock-erc7984.d.ts +134 -0
- package/dist/fhe/operators.d.ts +190 -0
- package/dist/fhe/react/index.cjs +102 -0
- package/dist/fhe/react/index.d.cts +10 -0
- package/dist/fhe/react/index.d.ts +10 -0
- package/dist/fhe/react/index.js +85 -0
- package/dist/fhe/react/use-decrypted-handle.d.ts +102 -0
- package/dist/fhe/scale-ratio.d.ts +168 -0
- package/dist/fhe/sepolia-encryptor-web.d.ts +101 -0
- package/dist/fhe/sepolia-encryptor.d.ts +132 -0
- package/dist/fhe/types.d.ts +62 -0
- package/dist/fhe-airdrop/abis/cloneable.d.ts +781 -0
- package/dist/fhe-airdrop/abis/factory.d.ts +714 -0
- package/dist/fhe-airdrop/abis/index.d.ts +2 -0
- package/dist/fhe-airdrop/advanced/factory-advanced.d.ts +53 -0
- package/dist/fhe-airdrop/advanced/index.cjs +21 -0
- package/dist/fhe-airdrop/advanced/index.d.cts +13 -0
- package/dist/fhe-airdrop/advanced/index.d.ts +13 -0
- package/dist/fhe-airdrop/advanced/index.js +8 -0
- package/dist/fhe-airdrop/advanced/react/index.cjs +61 -0
- package/dist/fhe-airdrop/advanced/react/index.d.cts +5 -0
- package/dist/fhe-airdrop/advanced/react/index.d.ts +5 -0
- package/dist/fhe-airdrop/advanced/react/index.js +59 -0
- package/dist/fhe-airdrop/advanced/react/usePredictAirdropAddress.d.ts +49 -0
- package/dist/fhe-airdrop/airdrop.d.ts +308 -0
- package/dist/fhe-airdrop/encryption.d.ts +109 -0
- package/dist/fhe-airdrop/errors.d.ts +60 -0
- package/dist/fhe-airdrop/factory.d.ts +281 -0
- package/dist/fhe-airdrop/index.cjs +227 -0
- package/dist/fhe-airdrop/index.d.cts +10 -0
- package/dist/fhe-airdrop/index.d.ts +10 -0
- package/dist/fhe-airdrop/index.js +10 -0
- package/dist/fhe-airdrop/react/_shared.d.ts +107 -0
- package/dist/fhe-airdrop/react/index.cjs +638 -0
- package/dist/fhe-airdrop/react/index.d.cts +90 -0
- package/dist/fhe-airdrop/react/index.d.ts +90 -0
- package/dist/fhe-airdrop/react/index.js +430 -0
- package/dist/fhe-airdrop/react/useAccessClaimAmount.d.ts +31 -0
- package/dist/fhe-airdrop/react/useAirdropCanExtendClaimWindow.d.ts +7 -0
- package/dist/fhe-airdrop/react/useAirdropClaim.d.ts +25 -0
- package/dist/fhe-airdrop/react/useAirdropClaimTypehash.d.ts +10 -0
- package/dist/fhe-airdrop/react/useAirdropClaimedSignatures.d.ts +16 -0
- package/dist/fhe-airdrop/react/useAirdropDeploymentBlockNumber.d.ts +6 -0
- package/dist/fhe-airdrop/react/useAirdropDomainSeparator.d.ts +8 -0
- package/dist/fhe-airdrop/react/useAirdropEndTime.d.ts +10 -0
- package/dist/fhe-airdrop/react/useAirdropFactoryCustomFee.d.ts +17 -0
- package/dist/fhe-airdrop/react/useAirdropFactoryDefaultGasFee.d.ts +10 -0
- package/dist/fhe-airdrop/react/useAirdropFactoryDisableCustomFee.d.ts +15 -0
- package/dist/fhe-airdrop/react/useAirdropFactoryFeeCollector.d.ts +11 -0
- package/dist/fhe-airdrop/react/useAirdropFactoryInitCodeHash.d.ts +17 -0
- package/dist/fhe-airdrop/react/useAirdropFactorySetCustomFee.d.ts +17 -0
- package/dist/fhe-airdrop/react/useAirdropFactorySetDefaultGasFee.d.ts +16 -0
- package/dist/fhe-airdrop/react/useAirdropFactorySetFeeCollector.d.ts +15 -0
- package/dist/fhe-airdrop/react/useAirdropGasFee.d.ts +11 -0
- package/dist/fhe-airdrop/react/useAirdropGrantRole.d.ts +16 -0
- package/dist/fhe-airdrop/react/useAirdropHasClaimEnded.d.ts +7 -0
- package/dist/fhe-airdrop/react/useAirdropHasClaimStarted.d.ts +7 -0
- package/dist/fhe-airdrop/react/useAirdropHasRole.d.ts +14 -0
- package/dist/fhe-airdrop/react/useAirdropIsClaimWindowActive.d.ts +9 -0
- package/dist/fhe-airdrop/react/useAirdropIsPaused.d.ts +8 -0
- package/dist/fhe-airdrop/react/useAirdropIsSignatureClaimed.d.ts +22 -0
- package/dist/fhe-airdrop/react/useAirdropIsSignatureValid.d.ts +50 -0
- package/dist/fhe-airdrop/react/useAirdropRevokeRole.d.ts +15 -0
- package/dist/fhe-airdrop/react/useAirdropStartTime.d.ts +10 -0
- package/dist/fhe-airdrop/react/useAirdropToken.d.ts +11 -0
- package/dist/fhe-airdrop/react/useAirdropWithdrawGasFee.d.ts +15 -0
- package/dist/fhe-airdrop/react/useAirdropWithdrawOtherConfidentialToken.d.ts +14 -0
- package/dist/fhe-airdrop/react/useAirdropWithdrawOtherToken.d.ts +14 -0
- package/dist/fhe-airdrop/react/useClaim.d.ts +29 -0
- package/dist/fhe-airdrop/react/useConfidentialAirdropFactoryImplementation.d.ts +11 -0
- package/dist/fhe-airdrop/react/useCreateAndFundConfidentialAirdrop.d.ts +33 -0
- package/dist/fhe-airdrop/react/useCreateAndFundConfidentialAirdropAndGetAddress.d.ts +40 -0
- package/dist/fhe-airdrop/react/useCreateConfidentialAirdrop.d.ts +29 -0
- package/dist/fhe-airdrop/react/useCreateConfidentialAirdropAndGetAddress.d.ts +31 -0
- package/dist/fhe-airdrop/react/useDisableCustomFee.d.ts +14 -0
- package/dist/fhe-airdrop/react/useExtendClaimWindow.d.ts +16 -0
- package/dist/fhe-airdrop/react/useFactoryCustomFee.d.ts +17 -0
- package/dist/fhe-airdrop/react/useFactoryDefaultGasFee.d.ts +10 -0
- package/dist/fhe-airdrop/react/useFactoryFeeCollector.d.ts +11 -0
- package/dist/fhe-airdrop/react/useFactoryInitCodeHash.d.ts +17 -0
- package/dist/fhe-airdrop/react/useFundConfidentialAirdrop.d.ts +25 -0
- package/dist/fhe-airdrop/react/useGetClaimAmount.d.ts +30 -0
- package/dist/fhe-airdrop/react/useSetCustomFee.d.ts +16 -0
- package/dist/fhe-airdrop/react/useSetDefaultGasFee.d.ts +15 -0
- package/dist/fhe-airdrop/react/useSetFeeCollector.d.ts +14 -0
- package/dist/fhe-airdrop/react/useSetPaused.d.ts +14 -0
- package/dist/fhe-airdrop/react/useSignClaimAuthorization.d.ts +31 -0
- package/dist/fhe-airdrop/react/useWithdraw.d.ts +12 -0
- package/dist/fhe-airdrop/react/useWithdrawOtherConfidentialToken.d.ts +13 -0
- package/dist/fhe-airdrop/react/useWithdrawOtherToken.d.ts +13 -0
- package/dist/fhe-airdrop/types.d.ts +21 -0
- package/dist/fhe-disperse/abis/index.d.ts +2 -0
- package/dist/fhe-disperse/abis/singleton.d.ts +1297 -0
- package/dist/fhe-disperse/abis/wallet.d.ts +111 -0
- package/dist/fhe-disperse/encryption.d.ts +77 -0
- package/dist/fhe-disperse/errors.d.ts +39 -0
- package/dist/fhe-disperse/index.cjs +248 -0
- package/dist/fhe-disperse/index.d.cts +14 -0
- package/dist/fhe-disperse/index.d.ts +14 -0
- package/dist/fhe-disperse/index.js +11 -0
- package/dist/fhe-disperse/react/_shared.d.ts +104 -0
- package/dist/fhe-disperse/react/index.cjs +752 -0
- package/dist/fhe-disperse/react/index.d.cts +82 -0
- package/dist/fhe-disperse/react/index.d.ts +82 -0
- package/dist/fhe-disperse/react/index.js +522 -0
- package/dist/fhe-disperse/react/useAccessEncryptedFeeReserve.d.ts +35 -0
- package/dist/fhe-disperse/react/useApproveTokenOnWallets.d.ts +25 -0
- package/dist/fhe-disperse/react/useBatchDiscloseHandlesToParty.d.ts +16 -0
- package/dist/fhe-disperse/react/useCalculateFee.d.ts +26 -0
- package/dist/fhe-disperse/react/useDeploymentBlockNumber.d.ts +11 -0
- package/dist/fhe-disperse/react/useDisableCustomFee.d.ts +20 -0
- package/dist/fhe-disperse/react/useDiscloseHandleToParty.d.ts +20 -0
- package/dist/fhe-disperse/react/useDisperse.d.ts +28 -0
- package/dist/fhe-disperse/react/useGetBatchLimits.d.ts +12 -0
- package/dist/fhe-disperse/react/useGetFeeConfig.d.ts +15 -0
- package/dist/fhe-disperse/react/useGetFees.d.ts +19 -0
- package/dist/fhe-disperse/react/useGetWallets.d.ts +19 -0
- package/dist/fhe-disperse/react/useGrantRole.d.ts +24 -0
- package/dist/fhe-disperse/react/useHasApprovedSubwallets.d.ts +25 -0
- package/dist/fhe-disperse/react/useHasRole.d.ts +22 -0
- package/dist/fhe-disperse/react/useIsPaused.d.ts +11 -0
- package/dist/fhe-disperse/react/useIsRegistered.d.ts +15 -0
- package/dist/fhe-disperse/react/usePause.d.ts +18 -0
- package/dist/fhe-disperse/react/usePredictWallets.d.ts +19 -0
- package/dist/fhe-disperse/react/usePreflightDisperse.d.ts +37 -0
- package/dist/fhe-disperse/react/useRecoverERC20FromWallets.d.ts +21 -0
- package/dist/fhe-disperse/react/useRecoverFromWallets.d.ts +21 -0
- package/dist/fhe-disperse/react/useRegister.d.ts +40 -0
- package/dist/fhe-disperse/react/useRescueConfidentialTokens.d.ts +21 -0
- package/dist/fhe-disperse/react/useRescueERC20.d.ts +21 -0
- package/dist/fhe-disperse/react/useRevokeRole.d.ts +24 -0
- package/dist/fhe-disperse/react/useRevokeTokenOnWallets.d.ts +24 -0
- package/dist/fhe-disperse/react/useSetCustomFee.d.ts +24 -0
- package/dist/fhe-disperse/react/useSetFeeConfig.d.ts +23 -0
- package/dist/fhe-disperse/react/useSetMaxBatchSizeDirect.d.ts +20 -0
- package/dist/fhe-disperse/react/useSetMaxBatchSizeHolding.d.ts +20 -0
- package/dist/fhe-disperse/react/useSetMaxBatchSizeTokenFee.d.ts +20 -0
- package/dist/fhe-disperse/react/useSingletonBatchDiscloseHandlesToParty.d.ts +13 -0
- package/dist/fhe-disperse/react/useSingletonBatchLimits.d.ts +12 -0
- package/dist/fhe-disperse/react/useSingletonCalculateFee.d.ts +26 -0
- package/dist/fhe-disperse/react/useSingletonDeploymentBlockNumber.d.ts +11 -0
- package/dist/fhe-disperse/react/useSingletonDisableCustomFee.d.ts +21 -0
- package/dist/fhe-disperse/react/useSingletonDiscloseHandleToParty.d.ts +17 -0
- package/dist/fhe-disperse/react/useSingletonFees.d.ts +19 -0
- package/dist/fhe-disperse/react/useSingletonGrantRole.d.ts +26 -0
- package/dist/fhe-disperse/react/useSingletonHasApprovedSubwallets.d.ts +25 -0
- package/dist/fhe-disperse/react/useSingletonHasRole.d.ts +23 -0
- package/dist/fhe-disperse/react/useSingletonIsPaused.d.ts +11 -0
- package/dist/fhe-disperse/react/useSingletonIsRegistered.d.ts +15 -0
- package/dist/fhe-disperse/react/useSingletonPause.d.ts +19 -0
- package/dist/fhe-disperse/react/useSingletonPredictWallets.d.ts +19 -0
- package/dist/fhe-disperse/react/useSingletonRevokeRole.d.ts +26 -0
- package/dist/fhe-disperse/react/useSingletonSetCustomFee.d.ts +25 -0
- package/dist/fhe-disperse/react/useSingletonUnpause.d.ts +18 -0
- package/dist/fhe-disperse/react/useSingletonWalletImplementation.d.ts +12 -0
- package/dist/fhe-disperse/react/useSingletonWallets.d.ts +19 -0
- package/dist/fhe-disperse/react/useSingletonWithdrawGasFee.d.ts +21 -0
- package/dist/fhe-disperse/react/useSingletonWithdrawTokenFee.d.ts +50 -0
- package/dist/fhe-disperse/react/useUnpause.d.ts +17 -0
- package/dist/fhe-disperse/react/useWalletImplementation.d.ts +12 -0
- package/dist/fhe-disperse/react/useWithdrawGasFee.d.ts +26 -0
- package/dist/fhe-disperse/react/useWithdrawTokenFee.d.ts +70 -0
- package/dist/fhe-disperse/singleton.d.ts +442 -0
- package/dist/fhe-disperse/subtotals.d.ts +14 -0
- package/dist/fhe-disperse/types.d.ts +332 -0
- package/dist/fhe-disperse/validate.d.ts +78 -0
- package/dist/fhe-vesting/abis/factory.d.ts +676 -0
- package/dist/fhe-vesting/abis/index.d.ts +3 -0
- package/dist/fhe-vesting/abis/manager.d.ts +1797 -0
- package/dist/fhe-vesting/advanced/factory-advanced.d.ts +52 -0
- package/dist/fhe-vesting/advanced/index.cjs +21 -0
- package/dist/fhe-vesting/advanced/index.d.cts +12 -0
- package/dist/fhe-vesting/advanced/index.d.ts +12 -0
- package/dist/fhe-vesting/advanced/index.js +8 -0
- package/dist/fhe-vesting/advanced/react/index.cjs +75 -0
- package/dist/fhe-vesting/advanced/react/index.d.cts +5 -0
- package/dist/fhe-vesting/advanced/react/index.d.ts +5 -0
- package/dist/fhe-vesting/advanced/react/index.js +73 -0
- package/dist/fhe-vesting/advanced/react/usePredictManagerAddress.d.ts +41 -0
- package/dist/fhe-vesting/encryption.d.ts +104 -0
- package/dist/fhe-vesting/errors.d.ts +183 -0
- package/dist/fhe-vesting/factory.d.ts +207 -0
- package/dist/fhe-vesting/index.cjs +269 -0
- package/dist/fhe-vesting/index.d.cts +9 -0
- package/dist/fhe-vesting/index.d.ts +9 -0
- package/dist/fhe-vesting/index.js +12 -0
- package/dist/fhe-vesting/manager.d.ts +808 -0
- package/dist/fhe-vesting/react/_shared.d.ts +122 -0
- package/dist/fhe-vesting/react/index.cjs +1054 -0
- package/dist/fhe-vesting/react/index.d.cts +123 -0
- package/dist/fhe-vesting/react/index.d.ts +123 -0
- package/dist/fhe-vesting/react/index.js +771 -0
- package/dist/fhe-vesting/react/useAcceptVestingTransfer.d.ts +12 -0
- package/dist/fhe-vesting/react/useAccessClaimableAmount.d.ts +14 -0
- package/dist/fhe-vesting/react/useAccessSettledAmount.d.ts +15 -0
- package/dist/fhe-vesting/react/useAccessTotalAllocation.d.ts +14 -0
- package/dist/fhe-vesting/react/useAccessVestedAmount.d.ts +26 -0
- package/dist/fhe-vesting/react/useAdminBatchDiscloseToParty.d.ts +16 -0
- package/dist/fhe-vesting/react/useAdminClaim.d.ts +9 -0
- package/dist/fhe-vesting/react/useAdminDiscloseToParty.d.ts +8 -0
- package/dist/fhe-vesting/react/useAdminGetClaimableAmount.d.ts +13 -0
- package/dist/fhe-vesting/react/useAdminGetSettledAmount.d.ts +13 -0
- package/dist/fhe-vesting/react/useAdminGetTokenBalance.d.ts +13 -0
- package/dist/fhe-vesting/react/useAdminGetTotalAllocation.d.ts +13 -0
- package/dist/fhe-vesting/react/useAdminGetVestedAmount.d.ts +15 -0
- package/dist/fhe-vesting/react/useAdminPartialClaim.d.ts +8 -0
- package/dist/fhe-vesting/react/useAllRecipients.d.ts +8 -0
- package/dist/fhe-vesting/react/useAllRecipientsLength.d.ts +6 -0
- package/dist/fhe-vesting/react/useAllRecipientsSliced.d.ts +13 -0
- package/dist/fhe-vesting/react/useBatchCreateVesting.d.ts +24 -0
- package/dist/fhe-vesting/react/useBatchDiscloseHandlesToParty.d.ts +13 -0
- package/dist/fhe-vesting/react/useBatchDiscloseToParty.d.ts +18 -0
- package/dist/fhe-vesting/react/useBatchRevokeVesting.d.ts +12 -0
- package/dist/fhe-vesting/react/useCancelVestingTransfer.d.ts +12 -0
- package/dist/fhe-vesting/react/useClaim.d.ts +19 -0
- package/dist/fhe-vesting/react/useConfidentialVestingFactoryImplementation.d.ts +11 -0
- package/dist/fhe-vesting/react/useCreateManager.d.ts +32 -0
- package/dist/fhe-vesting/react/useCreateManagerAndGetAddress.d.ts +31 -0
- package/dist/fhe-vesting/react/useCreateVesting.d.ts +38 -0
- package/dist/fhe-vesting/react/useDirectVestingTransfer.d.ts +13 -0
- package/dist/fhe-vesting/react/useDisableCustomFee.d.ts +14 -0
- package/dist/fhe-vesting/react/useDiscloseHandleToParty.d.ts +14 -0
- package/dist/fhe-vesting/react/useDiscloseToParty.d.ts +14 -0
- package/dist/fhe-vesting/react/useFactoryCustomFee.d.ts +17 -0
- package/dist/fhe-vesting/react/useFactoryDefaultFeeType.d.ts +11 -0
- package/dist/fhe-vesting/react/useFactoryDefaultGasFee.d.ts +10 -0
- package/dist/fhe-vesting/react/useFactoryDefaultTokenFee.d.ts +10 -0
- package/dist/fhe-vesting/react/useFactoryFeeCollector.d.ts +10 -0
- package/dist/fhe-vesting/react/useFactoryInitCodeHash.d.ts +18 -0
- package/dist/fhe-vesting/react/useGetClaimableAmount.d.ts +13 -0
- package/dist/fhe-vesting/react/useGetSettledAmount.d.ts +14 -0
- package/dist/fhe-vesting/react/useGetTotalAllocation.d.ts +13 -0
- package/dist/fhe-vesting/react/useGetVestedAmount.d.ts +25 -0
- package/dist/fhe-vesting/react/useGrantRole.d.ts +15 -0
- package/dist/fhe-vesting/react/useHasRole.d.ts +14 -0
- package/dist/fhe-vesting/react/useInitiateVestingTransfer.d.ts +12 -0
- package/dist/fhe-vesting/react/useIsRecipient.d.ts +10 -0
- package/dist/fhe-vesting/react/useManagerBatchDiscloseHandlesToParty.d.ts +15 -0
- package/dist/fhe-vesting/react/useManagerDeploymentBlockNumber.d.ts +7 -0
- package/dist/fhe-vesting/react/useManagerDiscloseHandleToParty.d.ts +16 -0
- package/dist/fhe-vesting/react/useManagerFactoryCustomFee.d.ts +17 -0
- package/dist/fhe-vesting/react/useManagerFactoryDefaultGasFee.d.ts +10 -0
- package/dist/fhe-vesting/react/useManagerFactoryDisableCustomFee.d.ts +15 -0
- package/dist/fhe-vesting/react/useManagerFactoryFeeCollector.d.ts +10 -0
- package/dist/fhe-vesting/react/useManagerFactoryInitCodeHash.d.ts +18 -0
- package/dist/fhe-vesting/react/useManagerFactorySetCustomFee.d.ts +19 -0
- package/dist/fhe-vesting/react/useManagerFactorySetDefaultGasFee.d.ts +13 -0
- package/dist/fhe-vesting/react/useManagerFactorySetFeeCollector.d.ts +14 -0
- package/dist/fhe-vesting/react/useManagerFee.d.ts +7 -0
- package/dist/fhe-vesting/react/useManagerFeeInfo.d.ts +18 -0
- package/dist/fhe-vesting/react/useManagerFeeType.d.ts +7 -0
- package/dist/fhe-vesting/react/useManagerGrantRole.d.ts +17 -0
- package/dist/fhe-vesting/react/useManagerHasRole.d.ts +15 -0
- package/dist/fhe-vesting/react/useManagerIsPausable.d.ts +6 -0
- package/dist/fhe-vesting/react/useManagerIsSplitEnabled.d.ts +6 -0
- package/dist/fhe-vesting/react/useManagerMaxBatchSize.d.ts +6 -0
- package/dist/fhe-vesting/react/useManagerMaxRevokeBatchSize.d.ts +6 -0
- package/dist/fhe-vesting/react/useManagerPause.d.ts +13 -0
- package/dist/fhe-vesting/react/useManagerPaused.d.ts +6 -0
- package/dist/fhe-vesting/react/useManagerRevokeRole.d.ts +17 -0
- package/dist/fhe-vesting/react/useManagerToken.d.ts +11 -0
- package/dist/fhe-vesting/react/useManagerUnpause.d.ts +12 -0
- package/dist/fhe-vesting/react/useManagerWithdrawGasFee.d.ts +14 -0
- package/dist/fhe-vesting/react/useManagerWithdrawOtherConfidentialToken.d.ts +14 -0
- package/dist/fhe-vesting/react/useManagerWithdrawOtherToken.d.ts +14 -0
- package/dist/fhe-vesting/react/useManagerWithdrawTokenFee.d.ts +11 -0
- package/dist/fhe-vesting/react/usePartialClaim.d.ts +15 -0
- package/dist/fhe-vesting/react/usePause.d.ts +12 -0
- package/dist/fhe-vesting/react/usePendingVestingTransfer.d.ts +20 -0
- package/dist/fhe-vesting/react/useRecipientVestings.d.ts +11 -0
- package/dist/fhe-vesting/react/useRecipientVestingsLength.d.ts +10 -0
- package/dist/fhe-vesting/react/useRecipientVestingsSliced.d.ts +12 -0
- package/dist/fhe-vesting/react/useRenounceRole.d.ts +16 -0
- package/dist/fhe-vesting/react/useResetGasFee.d.ts +10 -0
- package/dist/fhe-vesting/react/useResetTokenFee.d.ts +10 -0
- package/dist/fhe-vesting/react/useRevokeRole.d.ts +15 -0
- package/dist/fhe-vesting/react/useRevokeVesting.d.ts +15 -0
- package/dist/fhe-vesting/react/useRoleConstants.d.ts +19 -0
- package/dist/fhe-vesting/react/useSetCustomFee.d.ts +18 -0
- package/dist/fhe-vesting/react/useSetDefaultFeeType.d.ts +14 -0
- package/dist/fhe-vesting/react/useSetDefaultGasFee.d.ts +12 -0
- package/dist/fhe-vesting/react/useSetDefaultTokenFee.d.ts +13 -0
- package/dist/fhe-vesting/react/useSetFeeCollector.d.ts +13 -0
- package/dist/fhe-vesting/react/useSetMaxBatchSize.d.ts +12 -0
- package/dist/fhe-vesting/react/useSetMaxRevokeBatchSize.d.ts +12 -0
- package/dist/fhe-vesting/react/useSplitVesting.d.ts +28 -0
- package/dist/fhe-vesting/react/useTransferFeeCollectorRole.d.ts +12 -0
- package/dist/fhe-vesting/react/useUnpause.d.ts +11 -0
- package/dist/fhe-vesting/react/useVestingClaim.d.ts +19 -0
- package/dist/fhe-vesting/react/useVestingInfo.d.ts +25 -0
- package/dist/fhe-vesting/react/useWithdrawAdmin.d.ts +17 -0
- package/dist/fhe-vesting/react/useWithdrawGasFee.d.ts +13 -0
- package/dist/fhe-vesting/react/useWithdrawOtherConfidentialToken.d.ts +13 -0
- package/dist/fhe-vesting/react/useWithdrawOtherToken.d.ts +13 -0
- package/dist/fhe-vesting/react/useWithdrawTokenFee.d.ts +18 -0
- package/dist/fhe-vesting/types.d.ts +72 -0
- package/dist/index.cjs +237 -0
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +14 -0
- package/dist/telemetry/console.d.ts +29 -0
- package/dist/telemetry/index.cjs +113 -0
- package/dist/telemetry/index.d.cts +3 -0
- package/dist/telemetry/index.d.ts +3 -0
- package/dist/telemetry/index.js +102 -0
- package/dist/telemetry/tokenops.d.ts +15 -0
- package/package.json +316 -0
package/README.md
ADDED
|
@@ -0,0 +1,677 @@
|
|
|
1
|
+
# @tokenops/sdk
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@tokenops/sdk)
|
|
4
|
+
[](https://github.com/VestingLabs/tokenops-sdk/blob/main/LICENSE)
|
|
5
|
+
|
|
6
|
+
Typed viem-first SDK for TokenOps FHEVM contracts — confidential vesting, confidential airdrops, and confidential disperse. Works with [viem](https://viem.sh) `publicClient` / `walletClient` directly; no framework required.
|
|
7
|
+
|
|
8
|
+
**Deployed factories only.** The SDK calls into pre-deployed factories / singletons; there are no `deployFactory` helpers. Currently deployed: `@tokenops/sdk/fhe-vesting` (factory live on Sepolia), `@tokenops/sdk/fhe-airdrop` (factory live on Sepolia), `@tokenops/sdk/fhe-disperse` (singleton live on mainnet + Sepolia).
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
pnpm add @tokenops/sdk viem @zama-fhe/sdk@^3
|
|
14
|
+
# React hook subpaths additionally need:
|
|
15
|
+
pnpm add wagmi react react-dom @tanstack/react-query @zama-fhe/react-sdk@^3
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Node `>= 22` is required (constraint from `@zama-fhe/sdk`).
|
|
19
|
+
|
|
20
|
+
## Subpath layout
|
|
21
|
+
|
|
22
|
+
All subpaths are independently tree-shakeable. The `/react` paths keep React deps out of the server bundle.
|
|
23
|
+
|
|
24
|
+
| Subpath | Status | Description |
|
|
25
|
+
| ------------------------------------------ | ----------------------------------- | ---------------------------------------------------------------------------------- |
|
|
26
|
+
| `@tokenops/sdk` | stable | Root re-exports (version, core error types) |
|
|
27
|
+
| `@tokenops/sdk/telemetry` | stable | Telemetry sink adapters (`NoopTelemetry`, `ConsoleTelemetry`, `TokenOpsTelemetry`) |
|
|
28
|
+
| `@tokenops/sdk/fhe` | stable | FHE utility helpers (ratio scaling, encrypted-input types, operator helpers) |
|
|
29
|
+
| `@tokenops/sdk/fhe/react` | stable | React hooks for shared FHE utilities |
|
|
30
|
+
| `@tokenops/sdk/fhe-vesting` | factory live on Sepolia | Confidential vesting (LibClone + packed immutable args) |
|
|
31
|
+
| `@tokenops/sdk/fhe-vesting/react` | stable | React/wagmi hooks for confidential vesting |
|
|
32
|
+
| `@tokenops/sdk/fhe-vesting/advanced` | stable | Pre-mine address prediction (`predictManagerAddress`) |
|
|
33
|
+
| `@tokenops/sdk/fhe-vesting/advanced/react` | stable | React hooks for advanced vesting flows |
|
|
34
|
+
| `@tokenops/sdk/fhe-airdrop` | factory live on Sepolia | ConfidentialAirdrop (EIP-712 gated confidential claims) |
|
|
35
|
+
| `@tokenops/sdk/fhe-airdrop/react` | stable | React/wagmi hooks for confidential airdrops |
|
|
36
|
+
| `@tokenops/sdk/fhe-airdrop/advanced` | stable | Pre-mine address prediction (`predictAirdropAddress`) |
|
|
37
|
+
| `@tokenops/sdk/fhe-airdrop/advanced/react` | stable | React hooks for advanced airdrop flows |
|
|
38
|
+
| `@tokenops/sdk/fhe-disperse` | singleton live on mainnet + Sepolia | DisperseConfidential (singleton + per-user wallet-pair clones) |
|
|
39
|
+
| `@tokenops/sdk/fhe-disperse/react` | stable | React/wagmi hooks for confidential disperse |
|
|
40
|
+
|
|
41
|
+
The canonical exports map is in [`package.json`](https://github.com/VestingLabs/tokenops-sdk/blob/main/package.json) under `"exports"`.
|
|
42
|
+
|
|
43
|
+
## Quickstart — confidential vesting
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
import { createPublicClient, createWalletClient, http, parseEventLogs } from "viem";
|
|
47
|
+
import { sepolia } from "viem/chains";
|
|
48
|
+
import { privateKeyToAccount } from "viem/accounts";
|
|
49
|
+
import { RelayerNode, SepoliaConfig } from "@zama-fhe/sdk/node";
|
|
50
|
+
import {
|
|
51
|
+
createConfidentialVestingFactoryClient,
|
|
52
|
+
createConfidentialVestingManagerClient,
|
|
53
|
+
confidentialVestingManagerAbi,
|
|
54
|
+
erc7984OperatorAbi,
|
|
55
|
+
FeeType,
|
|
56
|
+
} from "@tokenops/sdk/fhe-vesting";
|
|
57
|
+
|
|
58
|
+
const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`);
|
|
59
|
+
const publicClient = createPublicClient({ chain: sepolia, transport: http(process.env.RPC_URL) });
|
|
60
|
+
const walletClient = createWalletClient({
|
|
61
|
+
account,
|
|
62
|
+
chain: sepolia,
|
|
63
|
+
transport: http(process.env.RPC_URL),
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// Build the Zama encryptor for Sepolia.
|
|
67
|
+
// SepoliaConfig provides all required contract addresses and the public relayer URL.
|
|
68
|
+
// Replace process.env.RPC_URL with a private endpoint for production traffic.
|
|
69
|
+
const encryptor = new RelayerNode({
|
|
70
|
+
transports: { [SepoliaConfig.chainId]: { ...SepoliaConfig, network: process.env.RPC_URL! } },
|
|
71
|
+
getChainId: async () => sepolia.id,
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
const factory = createConfidentialVestingFactoryClient({ publicClient, walletClient });
|
|
75
|
+
|
|
76
|
+
// Deploy the clone and read its address from the ManagerCreated event.
|
|
77
|
+
// The factory packs the deployment block number into the clone's immutable
|
|
78
|
+
// args, so predict-then-deploy is unreliable on a live chain — use the
|
|
79
|
+
// receipt-parsing helper instead.
|
|
80
|
+
const token = process.env.ERC7984_TOKEN_ADDRESS as `0x${string}`;
|
|
81
|
+
const userSalt = "0x0000000000000000000000000000000000000000000000000000000000000001" as const;
|
|
82
|
+
const { manager: managerAddress } = await factory.createManagerAndGetAddress({
|
|
83
|
+
token,
|
|
84
|
+
userSalt,
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
// Authorise the manager clone to spend the funder's confidential tokens.
|
|
88
|
+
// ERC-7984's setOperator uses a uint48 unix deadline (not uint256) — passing the
|
|
89
|
+
// wrong type encodes silently. Use the exported ABI to avoid the footgun.
|
|
90
|
+
|
|
91
|
+
const FAR_FUTURE: number = 2_000_000_000; // ~year 2033, uint48 deadline
|
|
92
|
+
await walletClient.writeContract({
|
|
93
|
+
address: token,
|
|
94
|
+
abi: erc7984OperatorAbi,
|
|
95
|
+
functionName: "setOperator",
|
|
96
|
+
args: [managerAddress, FAR_FUTURE],
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
// Create a vesting schedule. Pass a plaintext bigint — the SDK encrypts it.
|
|
100
|
+
// amount is raw token units: 1_000_000n = 1 USDC at 6 decimals, 1e18 for 18-decimal tokens.
|
|
101
|
+
const manager = createConfidentialVestingManagerClient({
|
|
102
|
+
publicClient,
|
|
103
|
+
walletClient,
|
|
104
|
+
address: managerAddress,
|
|
105
|
+
encryptor,
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
const vestingHash = await manager.createVesting({
|
|
109
|
+
params: {
|
|
110
|
+
recipient: "0xRecipientAddress" as `0x${string}`,
|
|
111
|
+
startTimestamp: Math.floor(Date.now() / 1000),
|
|
112
|
+
endTimestamp: Math.floor(Date.now() / 1000) + 365 * 86400,
|
|
113
|
+
cliffSeconds: 90 * 86400,
|
|
114
|
+
releaseIntervalSecs: 86400,
|
|
115
|
+
timelockSeconds: 0,
|
|
116
|
+
initialUnlockBps: 0,
|
|
117
|
+
cliffAmountBps: 0,
|
|
118
|
+
isRevocable: true,
|
|
119
|
+
},
|
|
120
|
+
amount: 1_000_000n,
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
// Extract the vestingId from the VestingCreated event in the receipt.
|
|
124
|
+
// vestingId is a bytes32 (Hex) used in all subsequent calls: claim, split, disclose, etc.
|
|
125
|
+
const receipt = await publicClient.waitForTransactionReceipt({ hash: vestingHash });
|
|
126
|
+
const events = parseEventLogs({
|
|
127
|
+
abi: confidentialVestingManagerAbi,
|
|
128
|
+
eventName: "VestingCreated",
|
|
129
|
+
logs: receipt.logs,
|
|
130
|
+
});
|
|
131
|
+
const vestingId = events[0]!.args.vestingId; // `0x${string}` — save this for later calls
|
|
132
|
+
|
|
133
|
+
// Claim vested tokens (recipient calls this).
|
|
134
|
+
// `ClaimArgs` is discriminated by the clone's `feeType` (read once via
|
|
135
|
+
// `manager.feeType()`):
|
|
136
|
+
// - FeeType.Gas → include `value: <wei>` (per-claim gas fee).
|
|
137
|
+
// - FeeType.DistributionToken → omit `value` (token fee deducted on-chain).
|
|
138
|
+
await manager.claim({ vestingId, feeType: FeeType.DistributionToken });
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
See [Confidential Vesting on docs.tokenops.xyz](https://docs.tokenops.xyz/sdk/fhe-vesting) for the full API reference.
|
|
142
|
+
|
|
143
|
+
### Quickstart — confidential vesting (React hooks)
|
|
144
|
+
|
|
145
|
+
Uses `@tokenops/sdk/fhe-vesting/react`. Requires `wagmi`, `@tanstack/react-query`, and `@zama-fhe/react-sdk` as additional peer deps.
|
|
146
|
+
|
|
147
|
+
```tsx
|
|
148
|
+
import { useQueryClient } from "@tanstack/react-query";
|
|
149
|
+
import { useZamaSDK } from "@zama-fhe/react-sdk";
|
|
150
|
+
import {
|
|
151
|
+
useCreateManagerAndGetAddress,
|
|
152
|
+
useCreateVesting,
|
|
153
|
+
useClaim,
|
|
154
|
+
useManagerFeeInfo,
|
|
155
|
+
FeeType,
|
|
156
|
+
type VestingParams,
|
|
157
|
+
} from "@tokenops/sdk/fhe-vesting/react";
|
|
158
|
+
|
|
159
|
+
// Wrap your app in wagmi's <WagmiProvider> + <QueryClientProvider> +
|
|
160
|
+
// @zama-fhe/react-sdk's <ZamaProvider> before rendering this component.
|
|
161
|
+
|
|
162
|
+
function VestingManager({ managerAddress }: { managerAddress: `0x${string}` }) {
|
|
163
|
+
const queryClient = useQueryClient();
|
|
164
|
+
const zamaSDK = useZamaSDK();
|
|
165
|
+
|
|
166
|
+
// Read the fee configuration once — needed to pass `value` on Gas-fee claims.
|
|
167
|
+
const { data: feeInfo } = useManagerFeeInfo({ address: managerAddress });
|
|
168
|
+
|
|
169
|
+
// Create a vesting schedule. Pass a plaintext bigint — the SDK encrypts it.
|
|
170
|
+
const create = useCreateVesting({
|
|
171
|
+
address: managerAddress,
|
|
172
|
+
// Lazy factory: the SDK calls this per-encryption, picking up the live
|
|
173
|
+
// ZamaSDK context at submit time rather than a stale mount-time capture.
|
|
174
|
+
// `useZamaSDK()` returns `ZamaSDK`; the encrypt-capable interface lives
|
|
175
|
+
// on `.relayer` (a `RelayerSDK`).
|
|
176
|
+
encryptor: () => zamaSDK.relayer,
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
// Claim vested tokens. For Gas-fee managers, attach `value = fee`.
|
|
180
|
+
const claim = useClaim({ address: managerAddress });
|
|
181
|
+
|
|
182
|
+
const params: VestingParams = {
|
|
183
|
+
recipient: "0xRecipient" as `0x${string}`,
|
|
184
|
+
startTimestamp: Math.floor(Date.now() / 1000),
|
|
185
|
+
endTimestamp: Math.floor(Date.now() / 1000) + 365 * 86400,
|
|
186
|
+
cliffSeconds: 0,
|
|
187
|
+
releaseIntervalSecs: 86400,
|
|
188
|
+
timelockSeconds: 0,
|
|
189
|
+
initialUnlockBps: 0,
|
|
190
|
+
cliffAmountBps: 0,
|
|
191
|
+
isRevocable: false,
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
return (
|
|
195
|
+
<div>
|
|
196
|
+
<button
|
|
197
|
+
onClick={() =>
|
|
198
|
+
create.mutate(
|
|
199
|
+
{ params, amount: 1_000_000n }, // 1 USDC at 6 decimals
|
|
200
|
+
{
|
|
201
|
+
onSuccess: () =>
|
|
202
|
+
queryClient.invalidateQueries({ queryKey: ["tokenops-sdk", "fhe-vesting"] }),
|
|
203
|
+
},
|
|
204
|
+
)
|
|
205
|
+
}
|
|
206
|
+
disabled={create.isPending}
|
|
207
|
+
>
|
|
208
|
+
Create vesting
|
|
209
|
+
</button>
|
|
210
|
+
|
|
211
|
+
<button
|
|
212
|
+
onClick={() =>
|
|
213
|
+
claim.mutate({
|
|
214
|
+
vestingId: "0xYourVestingId" as `0x${string}`,
|
|
215
|
+
value: feeInfo?.feeType === FeeType.Gas ? feeInfo.fee : undefined,
|
|
216
|
+
})
|
|
217
|
+
}
|
|
218
|
+
disabled={claim.isPending}
|
|
219
|
+
>
|
|
220
|
+
Claim
|
|
221
|
+
</button>
|
|
222
|
+
</div>
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// --- Deploy a manager clone first ---
|
|
227
|
+
|
|
228
|
+
function DeployManager({
|
|
229
|
+
token,
|
|
230
|
+
onDeployed,
|
|
231
|
+
}: {
|
|
232
|
+
token: `0x${string}`;
|
|
233
|
+
onDeployed: (manager: `0x${string}`) => void;
|
|
234
|
+
}) {
|
|
235
|
+
const queryClient = useQueryClient();
|
|
236
|
+
|
|
237
|
+
// Factory address resolves automatically from DEPLOYED_ADDRESSES on Sepolia/Mainnet.
|
|
238
|
+
const create = useCreateManagerAndGetAddress();
|
|
239
|
+
|
|
240
|
+
return (
|
|
241
|
+
<button
|
|
242
|
+
onClick={() =>
|
|
243
|
+
create.mutate(
|
|
244
|
+
{
|
|
245
|
+
token,
|
|
246
|
+
userSalt:
|
|
247
|
+
"0x0000000000000000000000000000000000000000000000000000000000000001" as `0x${string}`,
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
onSuccess: ({ manager }) => {
|
|
251
|
+
queryClient.invalidateQueries({ queryKey: ["tokenops-sdk", "fhe-vesting"] });
|
|
252
|
+
onDeployed(manager);
|
|
253
|
+
},
|
|
254
|
+
},
|
|
255
|
+
)
|
|
256
|
+
}
|
|
257
|
+
disabled={create.isPending}
|
|
258
|
+
>
|
|
259
|
+
{create.isPending ? "Deploying…" : "Deploy manager"}
|
|
260
|
+
</button>
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
See [Confidential Vesting — React hooks on docs.tokenops.xyz](https://docs.tokenops.xyz/sdk/fhe-vesting#react-hooks) for the full hook catalogue, encryptor wiring, address overrides, and query-key reference.
|
|
266
|
+
|
|
267
|
+
## Quickstart — confidential airdrop
|
|
268
|
+
|
|
269
|
+
```ts
|
|
270
|
+
import { createPublicClient, createWalletClient, http } from "viem";
|
|
271
|
+
import { sepolia } from "viem/chains";
|
|
272
|
+
import { privateKeyToAccount } from "viem/accounts";
|
|
273
|
+
import { RelayerNode, SepoliaConfig } from "@zama-fhe/sdk/node";
|
|
274
|
+
import {
|
|
275
|
+
createConfidentialAirdropFactoryClient,
|
|
276
|
+
createConfidentialAirdropClient,
|
|
277
|
+
encryptUint64,
|
|
278
|
+
signClaimAuthorization,
|
|
279
|
+
} from "@tokenops/sdk/fhe-airdrop";
|
|
280
|
+
|
|
281
|
+
const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`);
|
|
282
|
+
const rpcUrl = process.env.RPC_URL!;
|
|
283
|
+
const publicClient = createPublicClient({ chain: sepolia, transport: http(rpcUrl) });
|
|
284
|
+
const walletClient = createWalletClient({ account, chain: sepolia, transport: http(rpcUrl) });
|
|
285
|
+
|
|
286
|
+
const encryptor = new RelayerNode({
|
|
287
|
+
transports: { [SepoliaConfig.chainId]: { ...SepoliaConfig, network: rpcUrl } },
|
|
288
|
+
getChainId: () => Promise.resolve(sepolia.id),
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
// Factory address resolves automatically from DEPLOYED_ADDRESSES on Sepolia.
|
|
292
|
+
const factory = createConfidentialAirdropFactoryClient({
|
|
293
|
+
publicClient,
|
|
294
|
+
walletClient,
|
|
295
|
+
encryptor,
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
const now = Math.floor(Date.now() / 1000);
|
|
299
|
+
const userSalt = "0x0000000000000000000000000000000000000000000000000000000000000001" as const;
|
|
300
|
+
const token = process.env.TOKEN as `0x${string}`;
|
|
301
|
+
const params = {
|
|
302
|
+
token,
|
|
303
|
+
startTimestamp: now + 60,
|
|
304
|
+
endTimestamp: now + 30 * 86400,
|
|
305
|
+
canExtendClaimWindow: false,
|
|
306
|
+
admin: account.address,
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
// Deploy and read the clone address from the ConfidentialAirdropCreated event.
|
|
310
|
+
// (predictAirdropAddress also works — airdrop immutable args don't pack
|
|
311
|
+
// block.number, so the predicted address is stable across blocks.)
|
|
312
|
+
const { airdrop: airdropAddress } = await factory.createConfidentialAirdropAndGetAddress({
|
|
313
|
+
params,
|
|
314
|
+
userSalt,
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
// Admin: issue a signed claim authorization for a recipient. Bind the input
|
|
318
|
+
// proof to the RECIPIENT — Zama proofs commit to (contractAddress, userAddress)
|
|
319
|
+
// at encrypt time, and `FHE.fromExternal` on-chain rejects any other binding.
|
|
320
|
+
// amount is raw token units; ERC-7984 uses 6 decimals, so 1_000_000n = 1 token.
|
|
321
|
+
const recipient = "0xRecipientAddress" as `0x${string}`;
|
|
322
|
+
const encrypted = await encryptUint64({
|
|
323
|
+
encryptor,
|
|
324
|
+
contractAddress: airdropAddress,
|
|
325
|
+
userAddress: recipient,
|
|
326
|
+
value: 1_000_000n,
|
|
327
|
+
});
|
|
328
|
+
const signature = await signClaimAuthorization({
|
|
329
|
+
walletClient,
|
|
330
|
+
airdropAddress,
|
|
331
|
+
recipient,
|
|
332
|
+
encryptedAmountHandle: encrypted.handle,
|
|
333
|
+
});
|
|
334
|
+
// Deliver { encryptedInput: encrypted, signature } to the recipient via API / email / etc.
|
|
335
|
+
|
|
336
|
+
// User: claim tokens. The SDK submits the admin-issued pair verbatim — no
|
|
337
|
+
// re-encryption. (GAS_FEE() is fetched and attached as msg.value automatically.)
|
|
338
|
+
const airdrop = createConfidentialAirdropClient({
|
|
339
|
+
publicClient,
|
|
340
|
+
walletClient,
|
|
341
|
+
address: airdropAddress,
|
|
342
|
+
});
|
|
343
|
+
await airdrop.claim({ signature, encryptedInput: encrypted });
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
See [Confidential Airdrop on docs.tokenops.xyz](https://docs.tokenops.xyz/sdk/fhe-airdrop) for the full API reference and claim flow diagram.
|
|
347
|
+
|
|
348
|
+
### Quickstart — confidential airdrop (React hooks)
|
|
349
|
+
|
|
350
|
+
Uses `@tokenops/sdk/fhe-airdrop/react`. Requires `wagmi`, `@tanstack/react-query`, and `@zama-fhe/react-sdk` as additional peer deps.
|
|
351
|
+
|
|
352
|
+
```tsx
|
|
353
|
+
import { useQueryClient } from "@tanstack/react-query";
|
|
354
|
+
import { useZamaSDK } from "@zama-fhe/react-sdk";
|
|
355
|
+
import {
|
|
356
|
+
useCreateConfidentialAirdropAndGetAddress,
|
|
357
|
+
useSignClaimAuthorization,
|
|
358
|
+
useClaim,
|
|
359
|
+
encryptUint64,
|
|
360
|
+
} from "@tokenops/sdk/fhe-airdrop/react";
|
|
361
|
+
|
|
362
|
+
// Wrap your app in wagmi's <WagmiProvider> + <QueryClientProvider> +
|
|
363
|
+
// @zama-fhe/react-sdk's <ZamaProvider> before rendering these components.
|
|
364
|
+
|
|
365
|
+
// --- Admin: deploy a campaign and issue a claim authorization ---
|
|
366
|
+
|
|
367
|
+
function AdminPanel({
|
|
368
|
+
token,
|
|
369
|
+
recipient,
|
|
370
|
+
amount,
|
|
371
|
+
onCampaignReady,
|
|
372
|
+
}: {
|
|
373
|
+
token: `0x${string}`;
|
|
374
|
+
recipient: `0x${string}`;
|
|
375
|
+
amount: bigint;
|
|
376
|
+
onCampaignReady: (
|
|
377
|
+
airdrop: `0x${string}`,
|
|
378
|
+
payload: {
|
|
379
|
+
encryptedInput: { handle: `0x${string}`; inputProof: `0x${string}` };
|
|
380
|
+
signature: `0x${string}`;
|
|
381
|
+
},
|
|
382
|
+
) => void;
|
|
383
|
+
}) {
|
|
384
|
+
const queryClient = useQueryClient();
|
|
385
|
+
const zamaSDK = useZamaSDK();
|
|
386
|
+
|
|
387
|
+
// Factory address resolves automatically from DEPLOYED_ADDRESSES on Sepolia.
|
|
388
|
+
const create = useCreateConfidentialAirdropAndGetAddress();
|
|
389
|
+
|
|
390
|
+
// walletClient is pulled from wagmi's useWalletClient() internally.
|
|
391
|
+
const sign = useSignClaimAuthorization();
|
|
392
|
+
|
|
393
|
+
const now = Math.floor(Date.now() / 1000);
|
|
394
|
+
|
|
395
|
+
async function handleLaunch() {
|
|
396
|
+
const { airdrop } = await create.mutateAsync({
|
|
397
|
+
params: {
|
|
398
|
+
token,
|
|
399
|
+
startTimestamp: now + 60,
|
|
400
|
+
endTimestamp: now + 30 * 86400,
|
|
401
|
+
canExtendClaimWindow: false,
|
|
402
|
+
admin: "0xYourAdminAddress" as `0x${string}`,
|
|
403
|
+
},
|
|
404
|
+
userSalt:
|
|
405
|
+
"0x0000000000000000000000000000000000000000000000000000000000000001" as `0x${string}`,
|
|
406
|
+
});
|
|
407
|
+
|
|
408
|
+
queryClient.invalidateQueries({ queryKey: ["tokenops-sdk", "fhe-airdrop"] });
|
|
409
|
+
|
|
410
|
+
// Encrypt the allocation for the recipient.
|
|
411
|
+
const encrypted = await encryptUint64({
|
|
412
|
+
encryptor: zamaSDK.relayer,
|
|
413
|
+
contractAddress: airdrop,
|
|
414
|
+
userAddress: recipient,
|
|
415
|
+
value: amount,
|
|
416
|
+
});
|
|
417
|
+
|
|
418
|
+
// Sign the EIP-712 claim authorization.
|
|
419
|
+
const signature = await sign.mutateAsync({
|
|
420
|
+
airdropAddress: airdrop,
|
|
421
|
+
recipient,
|
|
422
|
+
encryptedAmountHandle: encrypted.handle,
|
|
423
|
+
});
|
|
424
|
+
|
|
425
|
+
// Deliver { encryptedInput: encrypted, signature } to the recipient via your API / email.
|
|
426
|
+
onCampaignReady(airdrop, { encryptedInput: encrypted, signature });
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
return (
|
|
430
|
+
<button onClick={handleLaunch} disabled={create.isPending || sign.isPending}>
|
|
431
|
+
{create.isPending ? "Deploying…" : sign.isPending ? "Signing…" : "Launch airdrop"}
|
|
432
|
+
</button>
|
|
433
|
+
);
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
// --- Recipient: claim tokens ---
|
|
437
|
+
|
|
438
|
+
function RecipientClaim({
|
|
439
|
+
airdropAddress,
|
|
440
|
+
claimPayload,
|
|
441
|
+
}: {
|
|
442
|
+
airdropAddress: `0x${string}`;
|
|
443
|
+
// The admin-issued payload — encryption bound to this recipient, handle
|
|
444
|
+
// committed to by the signature. The recipient submits it verbatim.
|
|
445
|
+
claimPayload: {
|
|
446
|
+
encryptedInput: { handle: `0x${string}`; inputProof: `0x${string}` };
|
|
447
|
+
signature: `0x${string}`;
|
|
448
|
+
};
|
|
449
|
+
}) {
|
|
450
|
+
const queryClient = useQueryClient();
|
|
451
|
+
const claim = useClaim({ address: airdropAddress });
|
|
452
|
+
|
|
453
|
+
return (
|
|
454
|
+
<button
|
|
455
|
+
onClick={() =>
|
|
456
|
+
claim.mutate(claimPayload, {
|
|
457
|
+
onSuccess: () =>
|
|
458
|
+
queryClient.invalidateQueries({ queryKey: ["tokenops-sdk", "fhe-airdrop"] }),
|
|
459
|
+
})
|
|
460
|
+
}
|
|
461
|
+
disabled={claim.isPending}
|
|
462
|
+
>
|
|
463
|
+
{claim.isPending ? "Claiming…" : "Claim tokens"}
|
|
464
|
+
</button>
|
|
465
|
+
);
|
|
466
|
+
}
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
See [Confidential Airdrop — React hooks on docs.tokenops.xyz](https://docs.tokenops.xyz/sdk/fhe-airdrop#react-hooks) for the full hook catalogue, encryptor wiring, address overrides, and query-key reference.
|
|
470
|
+
|
|
471
|
+
## Quickstart — confidential disperse
|
|
472
|
+
|
|
473
|
+
Confidential bulk payouts: see [Confidential Disperse on docs.tokenops.xyz](https://docs.tokenops.xyz/sdk/fhe-disperse) for the full API reference.
|
|
474
|
+
|
|
475
|
+
```ts
|
|
476
|
+
import { createPublicClient, createWalletClient, http } from "viem";
|
|
477
|
+
import { sepolia } from "viem/chains";
|
|
478
|
+
import { privateKeyToAccount } from "viem/accounts";
|
|
479
|
+
import { RelayerNode, SepoliaConfig } from "@zama-fhe/sdk/node";
|
|
480
|
+
import { createConfidentialDisperseClient } from "@tokenops/sdk/fhe-disperse";
|
|
481
|
+
|
|
482
|
+
const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`);
|
|
483
|
+
const rpcUrl = process.env.RPC_URL!;
|
|
484
|
+
const publicClient = createPublicClient({ chain: sepolia, transport: http(rpcUrl) });
|
|
485
|
+
const walletClient = createWalletClient({ account, chain: sepolia, transport: http(rpcUrl) });
|
|
486
|
+
|
|
487
|
+
const encryptor = new RelayerNode({
|
|
488
|
+
transports: { [SepoliaConfig.chainId]: { ...SepoliaConfig, network: rpcUrl } },
|
|
489
|
+
getChainId: () => Promise.resolve(sepolia.id),
|
|
490
|
+
});
|
|
491
|
+
|
|
492
|
+
// Singleton address resolves automatically from DEPLOYED_ADDRESSES on Sepolia and mainnet.
|
|
493
|
+
const client = createConfidentialDisperseClient({
|
|
494
|
+
publicClient,
|
|
495
|
+
walletClient,
|
|
496
|
+
encryptor,
|
|
497
|
+
});
|
|
498
|
+
|
|
499
|
+
const token = process.env.TOKEN as `0x${string}`;
|
|
500
|
+
|
|
501
|
+
// Register once to deploy your dedicated wallet pair.
|
|
502
|
+
const isRegistered = await client.isRegistered(account.address);
|
|
503
|
+
if (!isRegistered) {
|
|
504
|
+
await client.register({ token });
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
const recipients = ["0xRecipient1" as `0x${string}`, "0xRecipient2" as `0x${string}`];
|
|
508
|
+
const amounts = [1_000_000n, 500_000n]; // raw token units; ERC-7984 uses 6 decimals
|
|
509
|
+
|
|
510
|
+
// Preflight checks all five failure modes in one call.
|
|
511
|
+
const report = await client.preflightDisperse({
|
|
512
|
+
user: account.address,
|
|
513
|
+
token,
|
|
514
|
+
recipients,
|
|
515
|
+
amounts,
|
|
516
|
+
mode: "wallet",
|
|
517
|
+
});
|
|
518
|
+
if (!report.ready) {
|
|
519
|
+
// `report.blockerErrors` is `TokenOpsSdkError[]` — branch on `error.code`
|
|
520
|
+
// (e.g. `TOKENOPS_USER_NOT_REGISTERED`) for typed UI, or use `.message` for
|
|
521
|
+
// a quick string render. (The older `report.blockers: string[]` is still
|
|
522
|
+
// present for back-compat but will be removed in the next major.)
|
|
523
|
+
throw new Error(report.blockerErrors.map((e) => e.message).join("; "));
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
// Encrypt + disperse. The SDK encrypts amounts and subtotals, attaches the ETH gas fee.
|
|
527
|
+
const { hash } = await client.disperse({ token, mode: "wallet", recipients, amounts });
|
|
528
|
+
console.log("Disperse tx:", hash);
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
### Quickstart — confidential disperse (React hooks)
|
|
532
|
+
|
|
533
|
+
Uses `@tokenops/sdk/fhe-disperse/react`. Requires `wagmi`, `@tanstack/react-query`, and `@zama-fhe/react-sdk` as additional peer deps.
|
|
534
|
+
|
|
535
|
+
```tsx
|
|
536
|
+
import { useQueryClient } from "@tanstack/react-query";
|
|
537
|
+
import { useZamaSDK } from "@zama-fhe/react-sdk";
|
|
538
|
+
import {
|
|
539
|
+
useIsRegistered,
|
|
540
|
+
useRegister,
|
|
541
|
+
usePreflightDisperse,
|
|
542
|
+
useDisperse,
|
|
543
|
+
} from "@tokenops/sdk/fhe-disperse/react";
|
|
544
|
+
|
|
545
|
+
// Wrap your app in wagmi's <WagmiProvider> + <QueryClientProvider> +
|
|
546
|
+
// @zama-fhe/react-sdk's <ZamaProvider> before rendering these components.
|
|
547
|
+
|
|
548
|
+
// Singleton address resolves automatically from DEPLOYED_ADDRESSES on Sepolia + mainnet.
|
|
549
|
+
|
|
550
|
+
// --- Step 1: register (one-time per user) ---
|
|
551
|
+
|
|
552
|
+
function RegisterButton({ token, user }: { token: `0x${string}`; user: `0x${string}` }) {
|
|
553
|
+
const queryClient = useQueryClient();
|
|
554
|
+
const { data: isRegistered } = useIsRegistered({ user });
|
|
555
|
+
const register = useRegister();
|
|
556
|
+
|
|
557
|
+
return (
|
|
558
|
+
<button
|
|
559
|
+
onClick={() =>
|
|
560
|
+
register.mutate(
|
|
561
|
+
{ token },
|
|
562
|
+
{
|
|
563
|
+
onSuccess: () =>
|
|
564
|
+
queryClient.invalidateQueries({ queryKey: ["tokenops-sdk", "fhe-disperse"] }),
|
|
565
|
+
},
|
|
566
|
+
)
|
|
567
|
+
}
|
|
568
|
+
disabled={isRegistered === true || register.isPending}
|
|
569
|
+
>
|
|
570
|
+
{isRegistered ? "Registered" : register.isPending ? "Registering…" : "Register"}
|
|
571
|
+
</button>
|
|
572
|
+
);
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
// --- Step 2: preflight then disperse ---
|
|
576
|
+
|
|
577
|
+
function DispersePanel({
|
|
578
|
+
token,
|
|
579
|
+
recipients,
|
|
580
|
+
amounts,
|
|
581
|
+
user,
|
|
582
|
+
}: {
|
|
583
|
+
token: `0x${string}`;
|
|
584
|
+
recipients: `0x${string}`[];
|
|
585
|
+
amounts: bigint[];
|
|
586
|
+
user: `0x${string}`;
|
|
587
|
+
}) {
|
|
588
|
+
const queryClient = useQueryClient();
|
|
589
|
+
|
|
590
|
+
// Preflight: enabled when all args are present.
|
|
591
|
+
const { data: report } = usePreflightDisperse({
|
|
592
|
+
user,
|
|
593
|
+
token,
|
|
594
|
+
recipients,
|
|
595
|
+
amounts,
|
|
596
|
+
mode: "wallet",
|
|
597
|
+
});
|
|
598
|
+
|
|
599
|
+
// Lazy encryptor: SDK calls () => zamaSDK.relayer per-encryption so
|
|
600
|
+
// the live Zama React SDK context is always used (CLAUDE.md Pitfall #3).
|
|
601
|
+
const zamaSDK = useZamaSDK();
|
|
602
|
+
const disperse = useDisperse({
|
|
603
|
+
encryptor: () => zamaSDK.relayer,
|
|
604
|
+
});
|
|
605
|
+
|
|
606
|
+
return (
|
|
607
|
+
<div>
|
|
608
|
+
{report && !report.ready && (
|
|
609
|
+
<ul>
|
|
610
|
+
{report.blockerErrors.map((err) => (
|
|
611
|
+
// `err.code` is the stable machine-readable key (e.g.
|
|
612
|
+
// `TOKENOPS_USER_NOT_REGISTERED`); `err.message` is the prose.
|
|
613
|
+
<li key={err.code + err.message}>{err.message}</li>
|
|
614
|
+
))}
|
|
615
|
+
</ul>
|
|
616
|
+
)}
|
|
617
|
+
<button
|
|
618
|
+
onClick={() =>
|
|
619
|
+
disperse.mutate(
|
|
620
|
+
{ token, mode: "wallet", recipients, amounts },
|
|
621
|
+
{
|
|
622
|
+
onSuccess: () =>
|
|
623
|
+
queryClient.invalidateQueries({ queryKey: ["tokenops-sdk", "fhe-disperse"] }),
|
|
624
|
+
},
|
|
625
|
+
)
|
|
626
|
+
}
|
|
627
|
+
disabled={!report?.ready || disperse.isPending}
|
|
628
|
+
>
|
|
629
|
+
{disperse.isPending ? "Dispersing…" : "Disperse tokens"}
|
|
630
|
+
</button>
|
|
631
|
+
</div>
|
|
632
|
+
);
|
|
633
|
+
}
|
|
634
|
+
```
|
|
635
|
+
|
|
636
|
+
See [Confidential Disperse — React hooks on docs.tokenops.xyz](https://docs.tokenops.xyz/sdk/fhe-disperse#react-hooks) for the full hook catalogue, encryptor wiring, address overrides, `usePreflightDisperse` gating pattern, `useGetEncryptedFeeReserve` encrypted-view flow, and query-key reference.
|
|
637
|
+
|
|
638
|
+
## Peer dependencies
|
|
639
|
+
|
|
640
|
+
| Package | Range | Required for |
|
|
641
|
+
| ----------------------- | -------- | ------------------------------------------------------------------------------ |
|
|
642
|
+
| `viem` | `^2.47` | all subpaths (hard required) |
|
|
643
|
+
| `@zama-fhe/sdk` | `^3.0.0` | encryption + decryption + FHE write flows on every FHE subpath (optional peer) |
|
|
644
|
+
| `@zama-fhe/react-sdk` | `^3.0.0` | `/react` hook subpaths that submit encrypted inputs (optional peer) |
|
|
645
|
+
| `react` | `>=18` | `/react` hook subpaths (optional peer) |
|
|
646
|
+
| `wagmi` | `^2` | `/react` hook subpaths (optional peer) |
|
|
647
|
+
| `@tanstack/react-query` | `^5` | `/react` hook subpaths (optional peer) |
|
|
648
|
+
|
|
649
|
+
All peers except `viem` are marked `optional` via `peerDependenciesMeta` so read-only / ABI-only consumers can install the package without pulling them in. Install `@zama-fhe/sdk` explicitly the first time you encrypt, decrypt, or submit an FHE write; install the React peers if you use any `/react` hook subpath.
|
|
650
|
+
|
|
651
|
+
## Design
|
|
652
|
+
|
|
653
|
+
- **Single package, subpath exports.** No companion `@tokenops/react-sdk` — hooks live at `@tokenops/sdk/<product>/react`.
|
|
654
|
+
- **Deployed factories only.** No `deployFactory` helpers. Addresses live in `src/core/addresses.ts`.
|
|
655
|
+
- **Zama SDK v3 native.** FHE modules import from `@zama-fhe/sdk/viem` or `/node` directly. The SDK does not re-wrap the Zama surface.
|
|
656
|
+
- **Encapsulated FHE complexity.** Where a contract demands encrypted inputs, KMS proofs, scaled integers, and ACL grants, the SDK accepts natural plaintext inputs and handles the rest.
|
|
657
|
+
|
|
658
|
+
## Docs
|
|
659
|
+
|
|
660
|
+
- [Confidential Vesting (`@tokenops/sdk/fhe-vesting`)](https://docs.tokenops.xyz/sdk/fhe-vesting)
|
|
661
|
+
- [Confidential Airdrop (`@tokenops/sdk/fhe-airdrop`)](https://docs.tokenops.xyz/sdk/fhe-airdrop)
|
|
662
|
+
- [Confidential Disperse (`@tokenops/sdk/fhe-disperse`)](https://docs.tokenops.xyz/sdk/fhe-disperse)
|
|
663
|
+
- [Local dev with `link:`](https://docs.tokenops.xyz/sdk/local-dev)
|
|
664
|
+
|
|
665
|
+
## Development
|
|
666
|
+
|
|
667
|
+
```bash
|
|
668
|
+
pnpm install
|
|
669
|
+
pnpm typecheck # tsc --noEmit
|
|
670
|
+
pnpm build # tsup → dist/ (esm + cjs + dts per subpath)
|
|
671
|
+
pnpm test # vitest run
|
|
672
|
+
pnpm lint # eslint + prettier --check
|
|
673
|
+
```
|
|
674
|
+
|
|
675
|
+
## License
|
|
676
|
+
|
|
677
|
+
BSD-3-Clause-Clear. See [LICENSE](https://github.com/VestingLabs/tokenops-sdk/blob/main/LICENSE).
|