I have code working with Ethereum using nodejs and a send transaction. Is there an equivalent using eos? The basic task under ethereum is that A pays B with the server.js file making the transfer and the keys are stored in an .env variable, then web3 enables the txn.
The key line is in ethereum -
web3js.eth.sendRawTransaction
I assume eos has some kind of equivalent payment? Any tips are welcome.
Here is my ethereum code (testnet) -
app.post("/api/makePayment",function(req,res){ var payAmount = req.body.payAmount; //n// var payeeAccount = req.body.payeeAccount; //n var freqPayment = req.body.freqPayment; //n var myAddress = "0xd3a20af365538c2090f7b81496a83365c2489b3b"; localContractABI= [ { "constant": false, "inputs": [ { "name": "payeeWallet", "type": "address" } ], "name": "addPayeeWalle t", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "payeeWallet", "type": "address" } ], "name": "payWallet", "outputs": [ { "name": "success", "type": "bool" } ], "p ayable": true, "stateMutability": "payable", "type": "function" }, { "inputs": [], "payable": false, "stateMutability": "nonp ayable", "type": "constructor" }, { "constant": true, "inputs": [], "name": "owner", "outputs": [ { "name": "", "type": "addr ess" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [ { "name": "", "t ype": "address" } ], "name": "PayeeWallets", "outputs": [ { "name": "PayeeAllowed", "type": "bool" } ], "payable": false, "st ateMutability": "view", "type": "function" } ] localContractAddress="0xe28497515f9a57b16b92102eaa0b407f7f20d6d4"; //var infuraApiKey =process.env.INFURA_API_KEY; // var privateKey = process.env.PRIVATE_KEY; var web3js = new web3(new web3.providers.HttpProvider("http://178.128.172.167:8501")); web3js.eth.defaultAccount = myAddress; var privateKey=new Buffer(process.env.PAYMENT_PRIVATE_KEY, 'hex'); // var toAddress = 'ADRESS_TO_SEND_TRANSACTION'; //contract abi is the array that you can get from the ethereum wallet or etherscan var contractABI =localContractABI; var contractAddress =localContractAddress; //creating contract object var contract = web3js.eth.contract(contractABI).at(contractAddress); var count; var nounce; var errcode=""; // var apiKeyHash = web3js.sha3(authKey); var chainId = 1515; web3js.eth.getTransactionCount(myAddress, function(err, result) { nounce=result; var nounceHex = web3js.toHex(nounce); var rawTransaction = { "from":myAddress, "gasPrice":web3js.toHex(2*1e9), "gasLimit":web3js.toHex(90000), "to":payeeAccount, "value": web3js.toHex(web3js.toWei(payAmount, 'wei')), // must be in hex "chainId": web3js.toHex(chainId), // must be in hex // "data":contract.payWallet.getData(payeeAccount), "nonce":nounceHex} var transaction = new Tx(rawTransaction); transaction.sign(privateKey); var serializedTx = transaction.serialize(); web3js.eth.sendRawTransaction('0x'+serializedTx.toString('hex'), function(err1, hash) { if (!err1) { res.json({ message:hash}); } else res.json({ message:err1}); }); // raw }) //get });