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

grezi task4 update #1486

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
13 changes: 13 additions & 0 deletions grezi/README.md
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions grezi/env-sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
PRIV_KEYS="private key"
INERY_NAME="name account"

89 changes: 89 additions & 0 deletions grezi/grezi.mjs
Original file line number Diff line number Diff line change
@@ -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")