Created
August 21, 2025 00:35
-
-
Save JustMaier/171c9749ef7e2cfa92b4d79ccaf5ba93 to your computer and use it in GitHub Desktop.
Demo how to properly encode proofs for fulfillIntent
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Helper function to encode proof as bytes for smart contract | |
| function encodeReclaimProof(proofData: any): `0x${string}` { | |
| // Convert signature object to bytes array | |
| const claimSigArray = Array.from({ length: 65 }, (_, i) => | |
| proofData.signatures.claimSignature[i.toString()] || 0 | |
| ); | |
| // Check if this is an appclip proof (you may need to determine this from your proof data) | |
| const isAppclipProof = false; // Set this based on your proof type | |
| // Encode the proof | |
| const encodedProof = encodeAbiParameters( | |
| [ | |
| { | |
| type: 'tuple', | |
| components: [ | |
| { | |
| name: 'claimInfo', | |
| type: 'tuple', | |
| components: [ | |
| { name: 'provider', type: 'string' }, | |
| { name: 'parameters', type: 'string' }, | |
| { name: 'context', type: 'string' } | |
| ] | |
| }, | |
| { | |
| name: 'signedClaim', | |
| type: 'tuple', | |
| components: [ | |
| { | |
| name: 'claim', | |
| type: 'tuple', | |
| components: [ | |
| { name: 'identifier', type: 'bytes32' }, | |
| { name: 'owner', type: 'address' }, | |
| { name: 'timestampS', type: 'uint32' }, | |
| { name: 'epoch', type: 'uint32' } | |
| ] | |
| }, | |
| { | |
| name: 'signatures', | |
| type: 'bytes[]' | |
| } | |
| ] | |
| }, | |
| { | |
| name: 'isAppclipProof', | |
| type: 'bool' | |
| } | |
| ] | |
| } | |
| ], | |
| [ | |
| { | |
| claimInfo: { | |
| provider: proofData.claim.provider, | |
| parameters: proofData.claim.parameters, | |
| context: proofData.claim.context | |
| }, | |
| signedClaim: { | |
| claim: { | |
| identifier: proofData.claim.identifier as `0x${string}`, | |
| owner: proofData.claim.owner as `0x${string}`, | |
| timestampS: proofData.claim.timestampS, | |
| epoch: proofData.claim.epoch | |
| }, | |
| signatures: [`0x${Buffer.from(claimSigArray).toString('hex')}` as `0x${string}`] | |
| }, | |
| isAppclipProof: isAppclipProof | |
| } | |
| ] | |
| ); | |
| return encodedProof; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment