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

wundiyasuka update task4 #1477

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
17 changes: 17 additions & 0 deletions wundiyasuka/Config-Inery.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Api, JsonRpc, JsSignatureProvider } from "ineryjs";
import dotenv from "dotenv";
dotenv.config();

const url = "http://74.208.122.244:8888";

const json_rpc = new JsonRpc(url);
const account = "wundiyasuka";
const actor = "wundiyasuka";
const signature = new JsSignatureProvider([process.env.PRIVATE_KEY]);

const Userapi = new Api({
rpc: json_rpc,
signatureProvider: signature,
});

export { Userapi, account, actor };
31 changes: 31 additions & 0 deletions wundiyasuka/Destroy-Transaction.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Userapi, account, actor } from "./config-inery.js";

const Destroy = async (id) => {
try {
const hashId = await Userapi.transact(
{
actions: [
{
account,
name: "destroy",
authorization: [
{
actor,
permission: "active",
},
],
data: {
id,
},
},
],
},
{ broadcast: true, sign: true }
);
console.log(hashId);
} catch (error) {
console.log(error);
}
};

Destroy(1050);
39 changes: 39 additions & 0 deletions wundiyasuka/Package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "wundiyasuka",
"version": "1.0.0",
"description": "Inery RPC API",
"main": "index.js",
"scripts": {
"doc": "jsdoc -c jsdoc.json",
"generate-docs": "jsdoc --configure jsdoc.json --verbose",
"build-web": "webpack --config webpack.config.js"
},
"author": "wundiyasuka",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/WundiNode/inery-testnet-faucet-tasks.git"
},
"homepage": "https://github.com/WundiNode/inery-testnet-faucet-tasks.git",
"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"
}
}
50 changes: 50 additions & 0 deletions wundiyasuka/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
## RPC API Inery Task 4

### Instal curl - Run command
```
sudo apt-get install curl
```

### Install NodeJS & NPM

- OS [Windows](https://nodejs.org/en/download/)
- OS Linux:
```
curl -fsSL https://deb.nodesource.com/setup_19.x | sudo -E bash - &&\
sudo apt-get install -y nodejs
```



## Running Command for Inery Task 4

**1. First change directory to `wundiyasuka`**

```shell
cd ./wundiyasuka
```


**2. Install dependencies**

```shell
npm install
```

**3. Create & edit `.env` file**
```
cp .env-sample .env
```


**4. Run the script**

```
npm run solution
```

**5. Run script for transaction**

```
npm run push
```
67 changes: 67 additions & 0 deletions wundiyasuka/Transaction-Inery.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { Userapi, account, actor } from "./config-inery.js";

const Create = async (id, user, data) => {
try {
const hashtx = await Userapi.transact(
{
actions: [
{
account,
name: "create",
authorization: [
{
actor,
permission: "active",
},
],
data: {
id,
user,
data,
},
},
],
},
{ broadcast: true, sign: true }
);

console.log(hashtx);
} catch (err) {
console.log(err);
}
};

const Read = async (id) => {
try {
const hashId = await Userapi.transact(
{
actions: [
{
account,
name: "read",
authorization: [
{
actor,
permission: "active",
},
],
data: {
id,
},
},
],
},
{ broadcast: true, sign: true }
);
console.log(hashId);
} catch (error) {
console.log(error);
}
};

const Push = async (HasId, user, data) => {
await Create(HasId, user, data);
await Read(HasId);
};

Push(10543230, account, "inery task4");