小编pac*_*man的帖子

web3 在广播交易时给出“错误:返回错误:无效的发件人”

我是 web3 和以太坊区块链的新手。我尝试使用以下代码广播交易,但它总是给我一个无效的发件人错误。示例代码如下所示。

const Tx = require('ethereumjs-tx').Transaction;

const Web3 = require('web3');
var url = 'https://ropsten.infura.io/v3/XXX';
const web3 = new Web3(new Web3.providers.HttpProvider(url));


const account1 = '0xaB7BXXX';
web3.eth.defaultAccount =  account1;



const privatekey1 = Buffer.from('fee069363aXXX','hex');


web3.eth.getTransactionCount(account1, (err, txCount) => {

        data = "0xXXX";
        const txObject = {
            nonce:    web3.utils.toHex(txCount),
            gasLimit: web3.utils.toHex(200000), 
            gasPrice: web3.utils.toHex(web3.utils.toWei('10', 'gwei')),
            data: data
                 }
        const tx = new Tx(txObject)
        tx.sign(privatekey1)

        const serializedTx = tx.serialize()
        const raw = '0x' + serializedTx.toString('hex')


        web3.eth.sendSignedTransaction(raw, (err, txHash) => {
            console.log('err:', err, 'txHash:', txHash)
        }) …
Run Code Online (Sandbox Code Playgroud)

javascript ethereum web3js

6
推荐指数
1
解决办法
1万
查看次数

socketio.emit 不起作用 netty socketio

我正在使用 java 的 socketio 和 netty,而且我对它们都是新手。

\n

我的客户端代码如下所示。

\n
<!DOCTYPE html>\n<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">\n<head>\n    <title >webSocket test</title>\n    <script src="http://code.jquery.com/jquery-1.12.4.min.js"></script>\n    <script src="https://cdn.socket.io/3.1.3/socket.io.min.js" integrity="sha384-cPwlPLvBTa3sKAgddT6krw0cJat7egBga3DJepJyrLl4Q9/5WLra3rrnMcyTyOnh" crossorigin="anonymous"></script>\n    < !-- New Bootstrap core CSS file-->\n    <!-- Optional Bootstrap theme file (generally not necessary to import) -->\n    <!- -jQuery file. Be sure to introduce before bootstrap.min.js -->\n\n    <!-- The latest Bootstrap core JavaScript file-->\n    <script type=" text/javascript">\n        $(function(){\n            /**\n             * The socket.emit("event name", "parameter data") method of the\n             front-end js is used when triggering the back-end …
Run Code Online (Sandbox Code Playgroud)

java socket.io spring-boot netty-socketio

2
推荐指数
1
解决办法
2042
查看次数

以太坊网络可以用作数据库吗

我们可以像数据库一样使用以太坊网络来存储数据吗?如果将其用作数据库,可能会出现哪些问题。

ethereum

-1
推荐指数
1
解决办法
1549
查看次数