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

How can I subscribe to all ether transaction events #1145

Closed
kot-begemot opened this issue Oct 26, 2017 · 8 comments
Closed

How can I subscribe to all ether transaction events #1145

kot-begemot opened this issue Oct 26, 2017 · 8 comments

Comments

@kot-begemot
Copy link

kot-begemot commented Oct 26, 2017

web3.js
version: 1.0.0-beta.24

I want to listen all ether transaction events and then write them into database once transferred value is bigger than 0. I went multiple times though the (documentation)[https://web3js.readthedocs.io/en/1.0/web3-eth.html#id56]. Can you point me the a page or tell where can I find any info about that?

@kot-begemot
Copy link
Author

Ok, I think the answer was this one

web3.eth.subscribe('pendingTransactions', function(error, result){})
.on("data", function(trxData){
  web3.eth.getTransaction(trxData).then(console.log);
});

Got confused due to #1144

@raahil190
Copy link

raahil190 commented Nov 2, 2017

This doesn't seem to work for me using geth 1.7.2 stable version. I get the following error after running this via node

connection not open on send()

My script is

var Web3 = require('web3')
var web3 = new Web3("ws://localhost:9546") // don't worry port is correctly set
web3.eth.subscribe('pendingTransactions', function(error, result){}) .on("data", function(trxData){ web3.eth.getTransaction(trxData).then(console.log); });

@raahil190
Copy link

how did you get it to work @kot-begemot ?

@kot-begemot
Copy link
Author

kot-begemot commented Nov 15, 2017

@raahil190 you might be missing core cors for ws port. Here is how I start my client

# go client
geth --datadir /PATH_TO_STORAGE --testnet --rpc --rpcaddr 127.0.0.1 --rpcport 8545 --ws --wsport 8585 --wsorigins="*"
# parity client
parity --port=30304 --jsonrpc-port=8546 --jsonrpc-interface=127.0.0.1 --ws-port=8586 --ws-origins="*" --chain=ropsten  --base-path=/PATH_TO_STORAGE

@raahil190
Copy link

@kot-begemot I can't seem to get it to work without the
--wsorigins "*" flag , that should make it pretty insecure I guess - or is there a way around it ?

@kot-begemot
Copy link
Author

@raahil190 Depends on your setup. Do you plan to make it available to whole internet?

@raahil190
Copy link

No - I plan to use it myself only. But if I don't use --wsorigins "*" it does not work @kot-begemot

@catalsdevelop
Copy link

catalsdevelop commented Apr 28, 2018

Maybe same error, when I start geth in docker. Without "--wsorigins *", I got connection not open on send() in my client. Add the cmd line args, it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants