2

I am trying to build a website that will allow multiple users to send Ethereum transactions without having to install a node. My server is running a node, which is configured to accept requests from any internet address, and it seems that I should be able to connect to the node from any device through a web browser. Is the Ethereum JavaScript API useful to doing this? Thank you!

1
  • Though possible, allowing RPC connections from any hosts is discouraged due to security implications. The usual pattern is to have server-side software that speaks to Ethereum node behind a firewall. Commented Jul 19, 2016 at 17:16

2 Answers 2

1

Yes, you can use web3.ETH.sendTransaction to Sends a transaction to the network.

web3.eth.sendTransaction(transactionObject [, callback])

Example

// compiled solidity source code using https://chriseth.github.io/cpp-ethereum/
var code = "603d80600c6000396000f3007c01000000000000000000000000000000000000000000000000000000006000350463c6888fa18114602d57005b6007600435028060005260206000f3";

web3.eth.sendTransaction({data: code}, function(err, address) {
  if (!err)
    console.log(address); // "0x7f9fade1c0d57a7af66ab4ead7c2eb7b11a91385"
});
4
  • This question does not answer regarding if you need or don't need a node running on users' side Commented Jul 19, 2016 at 16:25
  • @MikkoOhtamaa Why not? web3 can connect to any node right?
    – niksmac
    Commented Jul 19, 2016 at 16:32
  • Are you saying one should run publicly facing Ethereum node allowing RPC connections from any host? As far as I know running public RPC interface is highly discouraged due to security implications. Commented Jul 19, 2016 at 17:11
  • @MikkoOhtamaa yeah, i am aware of that. OP is not asking or seems to be worried about that.
    – niksmac
    Commented Jul 19, 2016 at 17:14
1

Set up your node, then create a public facing api that accepts signed raw transactions input. You could do this with hooked web3 and your users could use eth-lightwallet by ConsenSys.

signing.signTx(keystore, pwDerivedKey, rawTx, signingAddress, hdPathString)

Signs a transaction with the private key corresponding to signingAddress.

Inputs

  • keystore: An instance of the keystore with which to sign the TX with.
  • pwDerivedKey: the users password derived key (Uint8Array)
  • rawTx: Hex-string defining an RLP-encoded raw transaction.
  • signingAddress: hex-string defining the address to send the transaction from.
  • hdPathString: (Optional) A path at which to create the encryption keys.

Return value

Hex-string corresponding to the RLP-encoded raw transaction.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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