Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Commit

Permalink
Merge pull request #498 from blukat29/ollie/web3js-ext-design
Browse files Browse the repository at this point in the history
  • Loading branch information
blukat29 authored Sep 1, 2023
2 parents 87fa8db + 8340d48 commit 7782ad5
Show file tree
Hide file tree
Showing 10 changed files with 6,761 additions and 0 deletions.
54 changes: 54 additions & 0 deletions web3js-ext/example/valueTransfer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
const { Web3 } = require("web3");
const { KlaytnWeb3 } = require( "../dist/src");

const priv = "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80";
const addr = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266";
const to = "0x70997970c51812dc3a010c7d01b50e0d17dc79c8";
const url = "http://localhost:8545";
const contractAddr = "0x5FbDB2315678afecb367f032d93F642f64180aa3";
const data_increment = "0xd09de08a"; // Counter.sol:increment()

async function main() {
let provider = new Web3.providers.HttpProvider(url);

// let web3 = new Web3(addr);
let web3 = new KlaytnWeb3(provider);

let sender = web3.eth.accounts.privateKeyToAccount(priv);
console.log({ sender });

/*
let tx = {
from: sender.address,
to: to,
value: 1e9,
// nonce: await web3.eth.getTransactionCount(addr),
// gas: 21000,
// gasPrice: 25e9,
type: 0x08,
};
/*/
let tx = {
from: sender.address,
to: contractAddr,
value: 0,
nonce: await web3.eth.getTransactionCount(addr),
gas: 100_000,
gasPrice: 25e9,
data: data_increment,
data: "0xdeadbeef", // trigger error
type: 0x30,
}
//*/

let signResult = await web3.eth.accounts.signTransaction(tx, sender.privateKey);
console.log({ signResult });

let sendResult = await web3.eth.sendSignedTransaction(signResult.rawTransaction);
let txhash = sendResult.transactionHash;

let receipt = await web3.eth.getTransactionReceipt(txhash);
console.log({ receipt });
}

main().catch(console.err);
Loading

0 comments on commit 7782ad5

Please sign in to comment.