digiasset-lookup
v1.1.3
Published
Lookup tools to help with DigiByte DigiAssets
Downloads
30
Readme
digiasset-lookup
Serverless way to lookup digiasset and digibyte data. Below are instructions on how to get your access keys.
Installation
npm install digiasset-lookup
IPFS(Needed for getVote):
- Follow instructions at https://docs.ipfs.io/install/ipfs-desktop/
- Forward port 4001 to this machine
- If planning to run this all the time you may want to set IPFS to run on boot. In linux I did that by running
crontab -e
and adding@reboot /usr/local/bin/ipfs daemon
AWS S3 API Key(Needed for all commands):
- Create an account at https://aws.amazon.com/
- Services->IAM
- In left column: Policies
- Blue Create policy button
- JSON
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"s3:GetObjectAcl",
"s3:GetObject",
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3:::*/*",
"arn:aws:s3:::chaindata-digibyte"
]
}
]
}
- Blue Review policy button
- name: digiassetX_data
- Blue Create policy
- In left Column: Groups
- Blue Create Group Button
- Group Name: digiassetX_data
- Type digi into search then select digiassetX_data
- Blue Next Step Button
- Blue Create Group Button
- On left panel select Users
- Blue add user button
- user name: digiassetX_data
- Select: Programmatic access
- Blue Next: Permissions button
- select: digiassetX_data
- Blue Next: Tags button
- Blue Next: Review button
- Blue Create user button
- Copy Access key ID and Secret access key into config/config.js
- click Close(make sure you have copied keys there will not be a second chance.
Usage
//initialize
const lookup=require('digiasset-lookup');
lookup.initS3({
accessKeyId: 'Your AWS S3 API Access Key',
secretAccessKey:'Your AWS S3 API Secret Access Key'
});
//get an addresses data
let addressData=await lookup.getAddress('dgb1qunxh378eltj2jrwza5sj9grvu5xud43vqvudwh');
console.log(addressData);
//get if an address is KYC verified
let kycData=await lookup.getKYC('DSXnZTQABeBrJEU5b2vpnysoGiiZwjKKDY');
console.log(kycData);
//gets an assets rules
let rules=await lookup.getRules('Ua9hJ3q7zKnaRZS9E5frb3Ukon6aBNNgxLX3i5');
console.log(rules);
//get an exchange rate
let numberOfDGBsatsToEqual1DolarCanadian=await lookup.getExchangeRate({
address: "dgb1qunxh378eltj2jrwza5sj9grvu5xud43vqvudwh",
index: 0,
name: "CAD"
});
console.log(numberOfDGBsatsToEqual1DolarCanadian);