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 Inery : Arfiyan #1496

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
86 changes: 86 additions & 0 deletions arfiyan/TxMy.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import readline from 'readline'

import { Api, JsonRpc, JsSignatureProvider } from 'ineryjs/dist/index.js'
import * as dotenv from 'dotenv'
import { Sign } from 'crypto';
dotenv.config()

const rn = readline.createInterface({
input: process.stdin,
output: process.stdout
});

const PREV_KEYS = " " // Inery Key
const LOG_URL = new JsonRpc(process.env.VPS) // IP Address Yoyr VPS
const account = " " // Account Inery

// const id = 1000

const Proof = new JsSignatureProvider([PREV_KEYS]); // Signature
const CallThash = new Api({rpc: LOG_URL, signatureProvider: Proof}) // Auth

const mathCaptcha = async () => {
const num1 = Math.floor(Math.random() * 4);
const num2 = Math.floor(Math.random() * 4);
const operator = Math.random() > 0.4 ? "+" : "-";
const correctAnswer = operator === "+" ? (num1 + num2) : (num1 - num2);

const userAnswer = await new Promise((resolve) => {
rn.question(`You're not a robot?, Solve this math problem: ${num1} ${operator} ${num2} = `, resolve);
});

if (parseInt(userAnswer) === correctAnswer) {
console.log("Math captcha passed!");
rn.close();
return true;
} else {
console.log("Math captcha failed. Please try again.");
rn.close();
return false;
}
}

//const actor = "arfiyan"
const broadcast = true
const sign = true
const line = "++++++=======++++++"

async function Push_Create(id, user, data){
try{
const Transhash = await CallThash.transact({
actions:[
{account, name:'create',
authorization:[{actor:'arfiyan', permission:'active',}], data:{ id, user, data}}]})
console.log("\n\n", line, "Transaction CREATE details", line)
console.log(Transhash)
}catch(error){
console.log(error)}}
async function Push_Update(id, data){
try{
const Transhash = await CallThash.transact({
actions:[
{account, name:'update',
authorization:[{actor:'arfiyan', permission:'active',}], data:{id, data}}]})
console.log("\n\n", line, "Transaction UPDATE details", line)
console.log(Transhash)
}catch(error){
console.log(error)}}
async function Push_Destroy(id){
try{
const Transhash = await CallThash.transact({
actions:[
{account, name:'destroy',
authorization:[{actor:'arfiyan', permission:'active',}], data:{id}}]})
console.log("\n\n", line, "Transaction DESTROY details", line)
console.log(Transhash)
}catch(error){
console.log(error)}}
async function main(id, user, data){
if (await mathCaptcha()) {
await Push_Create(id, user, data)
await Push_Update(id, data)
await Push_Destroy(id)
} else {
console.log("Transaction cancelled due to failed math captcha.");
}
} main(11560,account,"CRUD DATA TRANSACTION")
3 changes: 3 additions & 0 deletions arfiyan/env-example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SCKey="key"
VPS=http://vmi1076416.contaboserver.net:8888
Acc="nn"
143 changes: 143 additions & 0 deletions arfiyan/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions arfiyan/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "call_arfiyan",
"version": "1.0.0",
"description": "rpc transaction for inery blockchain",
"main": "./TxMy.mjs",
"scripts": {
"Call": "node ./TxMy.mjs"
},
"author": "arfiyan",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/arfiyan81/inery-testnet-faucet-tasks"
},
"homepage": "https://github.com/arfiyan81/inery-testnet-faucet-tasks",
"dependencies": {
"dotenv": "^16.0.3",
"ineryjs": "github:inery-blockchain/ineryjs"
}
}
25 changes: 25 additions & 0 deletions arfiyan/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
## Before running this application it is highly recommended to prepare the necessary things as below.

- NodeJS
- NPM

### What needs to be done when running the application test

1. Your must in folder ```arfiyan```

2. Create ```.env``` With This Data :

- ```VPS``` Your Ip Address/VPS
- ```SCKey``` Your Private Key Inery
- ```Acc``` Your Account Name On Dashboard Inery

### After Success Create/Edit ```.env``` You Can Run With Command :

```
npm install
```
```
npm run Call
```

==== DONE ====