diff --git a/grezi/README.md b/grezi/README.md new file mode 100644 index 000000000..8c7a8648f --- /dev/null +++ b/grezi/README.md @@ -0,0 +1,13 @@ +-> Pre-Push + + +-> go to dir where u want to push this + +-> npm install +-> npm install dotenv +-> Create .env and edit the variable +PRIV_KEYS=YOUR PRIVATE KEY +INERY_NAME=YOUR INERY ACCOUNT + +-> push +node grezi.mjs diff --git a/grezi/env-sample b/grezi/env-sample new file mode 100644 index 000000000..b65fac747 --- /dev/null +++ b/grezi/env-sample @@ -0,0 +1,3 @@ +PRIV_KEYS="private key" +INERY_NAME="name account" + diff --git a/grezi/grezi.mjs b/grezi/grezi.mjs new file mode 100644 index 000000000..d6406b42c --- /dev/null +++ b/grezi/grezi.mjs @@ -0,0 +1,89 @@ +import { Api, JsonRpc, RpcError, JsSignatureProvider } from '/root/ineryjs/dist/index.js' +import * as dotenv from 'dotenv' +dotenv.config() + +const url = "http://IP_VPS:8888" + +const json_rpc = new JsonRpc(url) +const private_key = process.env.PRIV_KEYS +const actor = process.env.INERY_NAME + +const account = "grezi" +const signature = new JsSignatureProvider([private_key]); + +const api = new Api({ + rpc: json_rpc, + signatureProvider: signature +}) + +async function create(id, user, data){ + try{ + const tx = await api.transact({ + actions:[ + { + account, + name:"create", + authorization:[ + { + actor, + permission:"active" + } + ], + data:{ + id, user, data + } + } + ] + },{broadcast:true,sign:true}) + + + console.log("=======================================================================") + console.log("=================== CREATE transaction information ====================") + 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 destroy(id){ + try{ + const tx = await api.transact({ + actions:[ + { + account, + name:"destroy", + authorization:[ + { + actor, + permission:"active" + } + ], + data:{ + id + } + } + ] + },{broadcast:true,sign:true}) + + + console.log("=======================================================================") + console.log("================== DESTROY transaction information ====================") + 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 main(id, user, data){ + await create(id, user, data) + await destroy(id) +} + +main(1, account, "INERY TESTNET TASK4") \ No newline at end of file