Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

task 4 widya #1433

Open
wants to merge 1 commit into
base: task4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions widya/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Guide

## Node Js And Npm

## Clone ineryjs
- git clone https://github.com/inery-blockchain/ineryjs

## Create New Dir
- dir widya
- cd widya
- import all file to widya

## Edit And Push Npm
- cp sample-env .env
_ edit with nano
- npm install
- npm install dotenv
## Run
- node kons.mjs

- npm install pako
46 changes: 46 additions & 0 deletions widya/kons.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { Api, JsonRpc, RpcError, JsSignatureProvider } from '/root/ineryjs/dist/index.js'
import * as dotenv from 'dotenv'
dotenv.config()

const inp = "http://ip:8888"
const prov = new JsonRpc(inp)
const prikey = process.env.prkey
const actor = process.env.inery
const exhaust = new JsSignatureProvider([prikey]);
const exc = new Api({ rpc: prov, signatureProvider: exhaust })

async function txns(contract, action, data, actor, permission) {
try {
const tx = await exc.transact({
actions: [
{
account: contract,
name: action,
authorization: [{ actor, permission }],
data
}
]
}, { broadcast: true, sign: true })


console.log("=======================================================================")
console.log("===================== PUSH API RPC INERY HAS DONE =====================")
console.log("=======================================================================")
console.log(tx, "\n")
console.log("Response from contract :", tx.processed.action_traces[0].console)
console.log("\n")
}catch(error){
console.log(error)
}
}
async function create_sync(id, user, data) {
await txns("wdiya" "create", { id, user, data }, actor, "active")
}
async function destroy_sync(id) {
await txns("widya" "destroy", { id }, actor, "active")
}
async function main(id, user, data) {
await create_sync(id, user, data);
await destroy_sync(id);
}
main(148, process.env.inery)
39 changes: 39 additions & 0 deletions widya/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "inery",
"version": "1.0.0",
"description": "Inery API",
"main": "/root/ineryjs/dist/index.js",
"scripts": {
"doc": "jsdoc -c jsdoc.json",
"generate-docs": "jsdoc --configure jsdoc.json --verbose",
"build-web": "webpack --config webpack.config.js"
},
"author": "Inery",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/inery-blockchain/ineryjs"
},
"homepage": "https://github.com/inery-blockchain/ineryjs",
"dependencies": {
"bn.js": "^5.2.0",
"elliptic": "^6.5.4",
"hash.js": "^1.1.7",
"node-fetch": "^2.6.7",
"pako": "^2.0.3"
},
"devDependencies": {
"browser-fs-access": "^0.31.0",
"browserify": "^17.0.0",
"buffer": "^6.0.3",
"clean-jsdoc-theme": "^4.1.7",
"crypto-browserify": "^3.12.0",
"https-browserify": "^1.0.0",
"jsdoc": "^3.5.5",
"node-util": "^0.0.1",
"stream-http": "^3.2.0",
"url": "^0.11.0",
"webpack": "^5.74.0",
"webpack-cli": "^4.10.0"
}
}
2 changes: 2 additions & 0 deletions widya/sample-env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
prkey="private_key"
inery="inery_account"