Sign BabyJubJub
by passbird
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<!--
Import metakeep sdk.
You can also import npm package if you are using node for building website
e.g.
npm install metakeep@2.2.2
require(metakeep)
-->
<script src="https://cdn.jsdelivr.net/npm/metakeep@2.2.2/lib/index.js" integrity="sha256-XwEVfJ47JrjxB4a8Hyym7/kwX23rmtA1ZW6hbdCW090=" crossorigin="anonymous"></script>
</head>
</html>
JavaScript
/* Init SDK */
const sdk = new MetaKeep({
/* App id to configure UI */
appId: "dd77a047-1855-4fea-aa94-70136ce6b1f3",
});
/* Call sign. It returns a promise which returns when the operation succeeds.
Otherwise throws an error.
*/
async function sign() {
try {
const msgBigInt = BigInt(
"262654620713026669568689430873010625803728049924121243784502389097019475"
);
// MetaKeep expects the message to be a hex string with integer value
// in big endian format.
const message = "0x" + msgBigInt.toString(16).padStart(64, "0");
const signResponse = await sdk.signMessage(
// message
message,
// signing reason
"reason",
);
console.log("sign successful");
console.log(signResponse);
} catch (err) {
console.log("Error when trying to sign");
console.log(err.message || err);
}
}
sign();