
@windingtree/org.id-core
Core ORGiD Javascript library
Setup
yarn install @windingtree/org.id-core
Usage
Initialization
import { OrgIdContract } from '@windingtree/org.id-core';
const contract = new OrgIdContract(
'ropsten',
window.ethereum
);
Getting of ORGiD information
const orgId = '0xf94c83b1da7bc36989b6a4f25e51ce66dd0fc...';
contract
.getOrgId(orgId)
.then(result => {
if (result === null) {
console.log(`${orgId} not found`);
} else {
console.log(result);
}
})
.catch(console.error);
ORGiD creation
contract
.createOrgId(
'<RANDOM_BYTES32_STRING>',
'http://yourdomain.com/path/to/ORG.JSON',
'75000',
'100000000000',
transactionHash => {
console.log(`Transaction sent: ${transactionHash}`);
}
)
.then(result => {
if (result === null) {
console.log('ORGiD creation error');
} else {
console.log(result);
}
})
.catch(console.error);
Changing of the ORG.JSON URI
const orgId = '0xf94c83b1da7bc36989b6a4f25e51ce66dd0...';
contract
.setOrgJson(
orgId,
'http://yourdomain.com/NEW/path/to/ORG.JSON',
'<CURRENT_ORGiD_OWNER_ADDRESS>',
)
.then(result => {
if (result === null) {
console.log('ORG.JSON URI update error');
} else {
console.log(result);
}
})
.catch(console.error);
Transferring of the ORGiD ownership
const orgId = '0xf94c83b1da7bc36989b6a4f25e51ce66dd0fc...';
contract
.transferOrgIdOwnership(
orgId,
'<NEW_OWNER_ADDRESS>',
'<CURRENT_ORGiD_OWNER_ADDRESS>',
).
Getting of registered ORGiD's count
contract
.getOrgIdsCount()
.then(result => {
if (result === null) {
console.log('Unable to get the count of ORGiDs');
} else {
console.log(result);
}
})
.catch(console.error);
contract
.getOrgIds()
.then(result => {
if (result === null) {
console.log('Unable to get the list of ORGiDs');
} else {
console.log(result);
}
})
.catch(console.error);
contract
.getOrgIds(0, 20)
.then(result => {
if (result === null) {
console.log('Unable to get the list of ORGiDs');
} else {
console.log(result);
}
})
.catch(console.error);
Documentation
Generated docs
Todo
- Create typings for @windingtree/org.id