ethereum-attestation-service / eas-sdk

Ethereum Attestation Service - TypeScript/JavaScript SDK
MIT License
83 stars 39 forks source link

Offchain attestation fails without refUID #29

Closed ccamrobertson closed 1 year ago

ccamrobertson commented 1 year ago

This might just be a docs issue, however, the offchain example is failing for me because of refUID missing in the call to signOffchainAttestation as ethers runs into an issue when hashing:

/eas-sdk-test/node_modules/@ethersproject/bytes/lib/index.js:9
    return !!(value.toHexString);
                    ^

TypeError: Cannot read properties of undefined (reading 'toHexString')
    at isHexable (/eas-sdk-test/node_modules/@ethersproject/bytes/lib/index.js:9:21)
    at arrayify (/eas-sdk-test/node_modules/@ethersproject/bytes/lib/index.js:69:9)
    at _pack (/eas-sdk-test/node_modules/@ethersproject/solidity/lib/index.js:53:34)
    at /eas-sdk-test/node_modules/@ethersproject/solidity/lib/index.js:83:20
    at Array.forEach (<anonymous>)
    at pack (/eas-sdk-test/node_modules/@ethersproject/solidity/lib/index.js:82:11)
    at keccak256 (/eas-sdk-test/node_modules/@ethersproject/solidity/lib/index.js:89:39)
    at getOffchainUID (/eas-sdk-test/node_modules/@ethereum-attestation-service/eas-sdk/dist/utils.js:14:94)
    at Offchain.getOffchainUID (/eas-sdk-test/node_modules/@ethereum-attestation-service/eas-sdk/dist/offchain/offchain.js:59:43)
    at Offchain.signOffchainAttestation (/eas-sdk-test/node_modules/@ethereum-attestation-service/eas-sdk/dist/offchain/offchain.js:40:30)

Node.js v19.8.1

Setting refUID: '0x0000000000000000000000000000000000000000000000000000000000000000', solves this:

const newAttestationUID = await offchain.signOffchainAttestation({
  recipient: '0xFD50b031E778fAb33DfD2Fc3Ca66a1EeF0652165',
  // Unix timestamp of when attestation expires. (0 for no expiration)
  expirationTime: 0,
  // Unix timestamp of current time
  revocable: 0,
  time: 1671219636,
  nonce: 0,
  schema: "0xb16fa048b0d597f5a821747eba64efa4762ee5143e9a80600d0005386edfc995",
  refUID: '0x0000000000000000000000000000000000000000000000000000000000000000',
  data: encodedData,
}, signer);

Adding the revocable param has no influence, but worth noting if this is just a doc cleanup.

slavik0329 commented 1 year ago

@ccamrobertson Thank you so much for letting us know! This is now fixed in the README.