diff --git a/widya/README.md b/widya/README.md new file mode 100644 index 000000000..47f8febb2 --- /dev/null +++ b/widya/README.md @@ -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 diff --git a/widya/kons.mjs b/widya/kons.mjs new file mode 100644 index 000000000..10ddb47e7 --- /dev/null +++ b/widya/kons.mjs @@ -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) \ No newline at end of file diff --git a/widya/package.json b/widya/package.json new file mode 100644 index 000000000..d92dab529 --- /dev/null +++ b/widya/package.json @@ -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" + } +} diff --git a/widya/sample-env b/widya/sample-env new file mode 100644 index 000000000..630da77b5 --- /dev/null +++ b/widya/sample-env @@ -0,0 +1,2 @@ +prkey="private_key" +inery="inery_account" \ No newline at end of file