Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
@cennznet/crml-attestation
Advanced tools
cennznet's javascript library for supporting identity runtime
A sdk providing additional features for Cennznet's Identity Service.
$> npm i --save @cennznet/api
Alright, let's get started with the code. If you want the full demo code without the explanations, see the examples/folder
First create a file and name it index.js
and write the following two lines in:
const {Api} = require('@cennznet/api')
This loads up a version of the Attestation SDK that we will be using to call the code. This will be the foundation of your attestation requests.
In order to send claims, we have to create a wallet, to do so we need to import @cennznet/wallet
so go ahead and add these lines to your file under the attestation imports
const {SimpleKeyring, Wallet} = require('@cennznet/wallet')
const simpleKeyring = new SimpleKeyring();
const wallet = new Wallet();
Alright, now we will need an account from which to issue a claim from. Navigate to CENNZnet UI and create an account by navigating to Accounts -> Create Account and selecting "Raw Seed" on the dropdown.
Now that you've created that, let's create an object called "issuer" in your code under the wallet instantiation
const issuer = {
address: '<your address here>',
uri: '//test-account',
};
Substrate accepts a Uint-8 Array as the signing mechanism, and we have a string so we must convert it to a Uint-8 Array. If your seed is less than 32 characters long, use String.prototype.padEnd to pad it with blank lines so that it can become 32 characters long and is consistent with the seed.
In order to issue a claim to someone, we need to have some money, so navigate to the CENNZnet Faucet and transfer some money to your public address.
Alright, now that we've got our issuer account set up, we need to set up our holder account. Please follow the instructions on setting up an issuer account again, but do not fund it.
You should now create an object similar to this:
const holder = {
address: '<your new holder address here>',
uri: '//test-holder-account',
};
Add the following lines to your file:
async function main () {
simpleKeyring.addFromSeed(issuer.seed);
const api = await Api.create({provider: 'wss://rimu.unfrastructure.io/ws?apikey=***'});
const passphrase = '<insert issuer passphrase here>';
await wallet.createNewVault(passphrase);
await wallet.addKeyring(simpleKeyring);
api.setSigner(wallet);
const {attestation} = api;
}
main()
This spins up a version of our attestation api inside the main function, we will now be writing all of our code inside the main function
To create a claim add the following lines inside the main function
const topic = 'test';
const value = Uint8Array.from(...); // 256 bytes of raw data
const claim = attestation.setClaim(
holder.address,
topic,
value,
);
await claim.signAndSend(issuer.address, async ({result, event}) => {
if (result.isFinalized && events !== undefined) {
const { data } = events[0].event;
console.log(data)
}
});
Topics should be ASCII strings that don't have any non typeable characters and be at most 32 characters and Values should be 256 bytes of data.
If you've done everything properly, then you should get a response object of something similar to this:
FAQs
cennznet's javascript library for supporting identity runtime
The npm package @cennznet/crml-attestation receives a total of 2 weekly downloads. As such, @cennznet/crml-attestation popularity was classified as not popular.
We found that @cennznet/crml-attestation demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.