Solidity Web3交易回执返回null

时间:2018-08-13 02:45:37

标签: ethereum solidity web3 receipt

确实要解决此错误。 不断返回alert(“接收状态失败”),我无法修复它。有任何想法吗? 收据返回为空。我正在尝试验证交易,然后使用JQuery显示新添加的“小猫”。因此,用户可以将kitty kitty牢固地添加到kitty数组中,然后我要在HTML文件上显示kitty。

JS文件

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order
(
order_num integer  not null,
order_date datetime not null,
cust_id chat(' at line 1

实体文件

    (function (Contract) {
    var web3_instance;
    var instance;
    var accounts;

    function init(cb) {
        web3_instance = new Web3(
            (window.web3 && window.web3.currentProvider) ||
            new Web3.providers.HttpProvider(Contract.endpoint));
        accounts = web3.eth.accounts;
        var contract_interface = web3_instance.eth.contract(Contract.abi);
        instance = contract_interface.at(Contract.address);
        cb();
    }

function waitForReceipt(result, cb){
    web3_instance.eth.getTransactionReceipt(result, function(error, receipt){
        if(error){
        alert(error);
        }
        else if(receipt !== null){
        cb(receipt);
        }
        else{


        window.setTimeout(function(){
            waitForReceipt(result, cb);
        }, 5000);
        }
    })
    }

    function showBalance(){

        var balance = instance.balance;
        alert(instance.balance); // returns undefined
        $('#balance').append(balance);
    }

    function addKitty(){

    instance.addNewKitty.sendTransaction({from: accounts[0], gas:1000000,  value: "6000"}, function (error, result) { 

    if(error){
        alert(error);
        alert("2");
        }
        else{

            waitForReceipt(result, function(receipt){
            if(receipt.status === "0x1"){
                alert("got receipt");
            }
            else{
                alert("receipt status fail");
            }
            })
        }
    })

    }
    // function getMessage(cb) {
    //     instance.message(function (error, result) {
    //         cb(error, result);
    //     });
    // }

    $(document).ready(function () {

        init(function () {
            // getMessage(function (error, result) {
            //     if (error) {
            //         console.error("Could not get article:", error);
            //         return;
            //     }
            //     $('#message').append(result);
            // });
            $("#addKitty").click(function(){

            addKitty();
        });

        $("#updateBalance").click(function(){

            showBalance();
        });

        });
    });
})(Contracts['CryptoKitties']);

0 个答案:

没有答案