Skip to content

Instantly share code, notes, and snippets.

@kvhnuke
Created August 6, 2018 18:54
Show Gist options
  • Save kvhnuke/c26cea9a0cb56c209b121d8643506664 to your computer and use it in GitHub Desktop.
Save kvhnuke/c26cea9a0cb56c209b121d8643506664 to your computer and use it in GitHub Desktop.
web3 overide
const Web3 = require('web3')
const Web3Method = require('web3-core-method')
let web3 = new Web3('https://api.myetherwallet.com/eth')
let reqM = {
send(tx, cb) {
console.log(tx)
}
}
// web3.eth.extend({
// methods: [{
// name: 'signTransaction',
// call: 'eth_signTransaction',
// params: 1,
// requestManager: reqM
// }]
// })
// var method = new Web3Method({
// name: 'signTransaction',
// call: 'eth_signTransaction',
// params: 1,
// requestManager: reqM
// });
// method.attachToObject(web3.eth);
web3.eth.getGasPrice()
.then(console.log);
web3.eth.sendTransaction.method.accounts = {
wallet: [{
privateKey: true
}],
signTransaction(tx, privateKey) {
return new Promise((res)=>{
console.log(tx, privateKey, '-----')
res()
})
}
}
console.log(web3.eth.sendTransaction({
from: 0,
test: 123,
gasPrice: 4000001
}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment