0

I'm deploying a dapp with Meteor and Metamask.

I would like to send a transaction to the blockchain that is scheduled everyday and sends ETHER to a contract. This function works but when I use web3.eth.sendTransaction to call the function it opens the metamask notification menu and I must click submit.

Is there a way to do this "click" automatically and send the transaction directly from the Javascript file of Meteor?

metamask notification menu

2

MetaMask is used for end-user interactions. If you want to send a transaction from a server, in an automated way, you need to sign the transaction yourself. I recommend looking at ethereumjs-tx, which is what MetaMask uses internally.

  • So, it's not possible to use raw transaction on dapp developed with meteor and metamask? In the dapp that I'm developing I have other functions that use Metamask on the ropsten testnet. May I create a raw transactions in the same js of Meteor? How can I create? – Giulio Magnanini Sep 16 '17 at 7:06
  • You can always create raw transactions by signing transaction data, but it requires having the private key locally. Again, checking out ethereumjs-tx shows you how to sign a tx, but you have to have the private key to do it. – DanF Sep 27 '17 at 20:56
0

Look into sending a raw transaction. The issue is when connecting to web3 = injected web3, then you connect to metamask. If you just want to send eth to a contract everyday, then you'd probably just want to connect to your own node (or infura) and send the transaction that way.

  • So, it's not possible to use raw transaction on dapp developed with meteor and metamask? In the dapp that I'm developing I have other functions that use Metamask on the ropsten testnet. May I create a raw transactions in the same js of Meteor? How can I create? – Giulio Magnanini Sep 16 '17 at 7:07
  • Technically yes, but you wouldn't want to. If you go a little more in depth into what you're trying to do, we can probably help you more. But if you want to send a transaction, you need to sign it with a private key. So either you have metamask do that (click Submit), or you hardcode in a private key. If its just for you (not the dapp users), then you would be better off not having your private key in your code. If it is for your users, they probably won't want to trust you with their private keys (hence why we have metamask) – thefett Sep 16 '17 at 15:00
  • I'm developing a dapp that every 2 months send an amount of ether to all the subscribers, so if a person is registered, she must receive the 2 ethers, from a contract, every 2 months. My question is about: is possible to do it automatically without a person that click submit to every send transaction? How can I make it? I'm developing the app with meteor and metamask.I have a mongoDB database. I'm developing the app on the Ropsten testnet. I hope this can help you to help me! – Giulio Magnanini Sep 17 '17 at 7:28
  • It sounds similar to a dividend bearing token. There are a lot of examples out there, and the dapp in my mind would just be for the withdrawals. Here's a good starting point for you medium.com/@weka/… – thefett Sep 17 '17 at 21:17
  • In short: Users don't have to sign a transaction for you to send them ether, you just need to store their account address. – DanF Sep 18 '17 at 5:11
0

If you really need to do this through a website frontend, you can initialize web3 yourself and set up a local node as its provider, having an account permanently unlocked. This is, of course, risky, as you should disallow any connections to the node from anywhere than localhost.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.