nebulasio / neb.java

Java implementation of the Nebulas protocol
GNU Lesser General Public License v3.0
31 stars 18 forks source link

java如何发送交易?? #14

Open xiaoGreaat opened 6 years ago

xiaoGreaat commented 6 years ago

如何用java 发送交易 ? 有没有案例?

qq364390162 commented 6 years ago
        Transaction.PayloadType payloadType = Transaction.PayloadType.BINARY; // binary tx
        byte[] payload = new TransactionBinaryPayload(null).toBytes();
        BigInteger gasPrice = new BigInteger("1000000"); // 0 < gasPrice < 10^12
        BigInteger gasLimit = new BigInteger("200000"); // 20000 < gasPrice < 50*10^9
        Transaction tx = new Transaction(chainID, from, to, value, nonce + 1, payloadType, payload, gasPrice, gasLimit);

        manager.signTransaction(tx, passphrase);
        byte[] rawData = tx.toProto();
        String rawTransaction = Base64.toBase64String(rawData);

这个类型应该就是交易类型吧,但是我执行代码成功生成交易一直都是pending @yupnano 能帮忙看一下吗

yupnano commented 6 years ago

@qq364390162 是不是发送交易的账户没有余额呀,你可以贴一下pending的txhash看看。