Skip to content
Open

1313 #10

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
3 changes: 3 additions & 0 deletions .env-sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
INERY_ACCOUNT="INERY_HESAP_ADINIZ"
PRIVATE_KEY="INERY_PRIVATE_KEY"
NODE_URL="http://IP_ADRESINIZ:8888"
1 change: 1 addition & 0 deletions dsadjjsa.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
assdaaasd.txt
52 changes: 52 additions & 0 deletions example/json-rpc.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { Api, JsonRpc, RpcError, JsSignatureProvider } from '../dist/index.js'
import * as dotenv from 'dotenv' // see https://github.com/motdotla/dotenv#how-do-i-use-dotenv-with-import
dotenv.config()

// our Node URL, when we first setup our node, inery has created our RPC in port :8888
// check it on your node, /inery-node/inery.setup/tools/config.json HTTP_ADDRESS key
const url = process.env.NODE_URL

const json_rpc = new JsonRpc(url) // create new JsonRPC using our node url
const private_key = process.env.PRIVATE_KEY; // private key

const account = process.env.INERY_ACCOUNT // Inery Smart Contract Account to Call
const actor = process.env.INERY_ACCOUNT // The Signer, should match with your provided Private Key
const signature = new JsSignatureProvider([private_key]); // creating Signer from private key

// calling API
const api = new Api({
rpc: json_rpc,
signatureProvider: signature
})

// A Function to create new data in our Valued Smart Contract, and call "create" function on our Smart contract
async function create(id, user, data){
try{
// create new transaction and sign it
const tx = await api.transact({
actions:[
{
account,
name:"create",
authorization:[
{
actor,
permission:"active"
}
],
data:{
id, user, data
}
}
]
},{broadcast:true,sign:true})

console.log(tx) // output the tx to terminal, it's Json Object
console.log(tx.processed.action_traces[0].console)
}catch(error){
console.log(error)
}
}

// call RPC that we created in create function
create(5, account, "Create new Data via JSON RPC")
1 change: 1 addition & 0 deletions g
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hi