Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
edited title
Link

Web3JS string array incorrect return value

Edited syntax error in ABI
Source Link
<!DOCTYPE html>
<html lang="en">
<head></head>
<body>
    <script src="https://github.com/ethereum/web3.js/blob/develop/dist/web3.min.js" type="text"></script>
    <h1>My Test</h1>
    <div id="output"></div>
    <button id="button">Click</button>
    <script>
        window.addEventListener('load', function() {
            if(typeof web3 !== undefined) web3js = new Web3(web3.currentProvider);
            
            document.getElementById("button").addEventListener("click", function() {
                getMyStringArray();
            }, function(error, result){}, false);
        });

        var contractInstance;
        var contractABI = [

    {
        "constant": false,
        "inputs": [
            {
                "name": "newEntry",
                "type": "string"
            }
        ],
        "name": "addToMyStringArray",
        "outputs": [],"payable": 
 false,"stateMutability": ","type": "function"},{"inputs": [],    "payable": false,
        "stateMutability": "nonpayable",
        "type": "constructor""function"
    },
    {
        "constant": true,
        "inputs": [],
        "name": "getMyStringArray",
        "outputs": [
            {
                "name": "",
                "type": "string[]"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "inputs": [],
        "payable": false,
        "stateMutability": "nonpayable",
        "type": "constructor"
    } 
];
        var contractAddress = "0x8fcb440a8ba9df8ea91493be3bd27ab562d04386";
<!-- Contract Address is on the Rinkeby Test Network -->
        contractInstance = web3.eth.contract(contractABI).at(contractAddress);


        function getMyStringArray() {
            contractInstance.getMyStringArray(function(error, result){
                document.getElementById("output").innerHTML = result;
            });
        }
    </script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head></head>
<body>
    <script src="https://github.com/ethereum/web3.js/blob/develop/dist/web3.min.js" type="text"></script>
    <h1>My Test</h1>
    <div id="output"></div>
    <button id="button">Click</button>
    <script>
        window.addEventListener('load', function() {
            if(typeof web3 !== undefined) web3js = new Web3(web3.currentProvider);
            
            document.getElementById("button").addEventListener("click", function() {
                getMyStringArray();
            }, function(error, result){}, false);
        });

        var contractInstance;
        var contractABI = [{"constant": false,"inputs": [{"name": "newEntry","type": "string"}],"name": "addToMyStringArray","outputs": [],"payable": false,"stateMutability": ","type": "function"},{"inputs": [],"payable": false,"stateMutability": "nonpayable","type": "constructor"},{"constant": true,"inputs": [],"name": "getMyStringArray","outputs": [{"name": "","type": "string[]"}],"payable": false,"stateMutability": "view","type": "function"}];
        var contractAddress = "0x8fcb440a8ba9df8ea91493be3bd27ab562d04386";
<!-- Contract Address is on the Rinkeby Test Network -->
        contractInstance = web3.eth.contract(contractABI).at(contractAddress);


        function getMyStringArray() {
            contractInstance.getMyStringArray(function(error, result){
                document.getElementById("output").innerHTML = result;
            });
        }
    </script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head></head>
<body>
    <script src="https://github.com/ethereum/web3.js/blob/develop/dist/web3.min.js" type="text"></script>
    <h1>My Test</h1>
    <div id="output"></div>
    <button id="button">Click</button>
    <script>
        window.addEventListener('load', function() {
            if(typeof web3 !== undefined) web3js = new Web3(web3.currentProvider);
            
            document.getElementById("button").addEventListener("click", function() {
                getMyStringArray();
            }, function(error, result){}, false);
        });

        var contractInstance;
        var contractABI = [

    {
        "constant": false,
        "inputs": [
            {
                "name": "newEntry",
                "type": "string"
            }
        ],
        "name": "addToMyStringArray",
        "outputs": [], 
        "payable": false,
        "stateMutability": "nonpayable",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [],
        "name": "getMyStringArray",
        "outputs": [
            {
                "name": "",
                "type": "string[]"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "inputs": [],
        "payable": false,
        "stateMutability": "nonpayable",
        "type": "constructor"
    } 
];
        var contractAddress = "0x8fcb440a8ba9df8ea91493be3bd27ab562d04386";
<!-- Contract Address is on the Rinkeby Test Network -->
        contractInstance = web3.eth.contract(contractABI).at(contractAddress);


        function getMyStringArray() {
            contractInstance.getMyStringArray(function(error, result){
                document.getElementById("output").innerHTML = result;
            });
        }
    </script>
</body>
</html>
deleted 65 characters in body
Source Link
<!DOCTYPE html>
<html lang="en">
<head></head>
<body>
    <script src="https://github.com/ethereum/web3.js/blob/develop/dist/web3.min.js" type="text"></script>
    <h1>My Test</h1>
    <div id="output"></div>
    <button id="button">Click</button>
    <script src="./script.js" type="text/javascript"></script>
    <script>
        window.addEventListener('load', function() {
            if(typeof web3 !== undefined) web3js = new Web3(web3.currentProvider);
            
            document.getElementById("button").addEventListener("click", function() {
                getMyStringArray();
            }, function(error, result){}, false);
        });

        var contractInstance;
        var contractABI = [{"constant": false,"inputs": [{"name": "newEntry","type": "string"}],"name": "addToMyStringArray","outputs": [],"payable": false,"stateMutability": ","type": "function"},{"inputs": [],"payable": false,"stateMutability": "nonpayable","type": "constructor"},{"constant": true,"inputs": [],"name": "getMyStringArray","outputs": [{"name": "","type": "string[]"}],"payable": false,"stateMutability": "view","type": "function"}];
        var contractAddress = "0x8fcb440a8ba9df8ea91493be3bd27ab562d04386";
<!-- Contract Address is on the Rinkeby Test Network -->
        contractInstance = web3.eth.contract(contractABI).at(contractAddress);


        function getMyStringArray() {
            contractInstance.getMyStringArray(function(error, result){
                document.getElementById("output").innerHTML = result;
            });
        }
    </script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head></head>
<body>
    <script src="https://github.com/ethereum/web3.js/blob/develop/dist/web3.min.js" type="text"></script>
    <h1>My Test</h1>
    <div id="output"></div>
    <button id="button">Click</button>
    <script src="./script.js" type="text/javascript"></script>
    <script>
        window.addEventListener('load', function() {
            if(typeof web3 !== undefined) web3js = new Web3(web3.currentProvider);
            
            document.getElementById("button").addEventListener("click", function() {
                getMyStringArray();
            }, function(error, result){}, false);
        });

        var contractInstance;
        var contractABI = [{"constant": false,"inputs": [{"name": "newEntry","type": "string"}],"name": "addToMyStringArray","outputs": [],"payable": false,"stateMutability": ","type": "function"},{"inputs": [],"payable": false,"stateMutability": "nonpayable","type": "constructor"},{"constant": true,"inputs": [],"name": "getMyStringArray","outputs": [{"name": "","type": "string[]"}],"payable": false,"stateMutability": "view","type": "function"}];
        var contractAddress = "0x8fcb440a8ba9df8ea91493be3bd27ab562d04386";
<!-- Contract Address is on the Rinkeby Test Network -->
        contractInstance = web3.eth.contract(contractABI).at(contractAddress);


        function getMyStringArray() {
            contractInstance.getMyStringArray(function(error, result){
                document.getElementById("output").innerHTML = result;
            });
        }
    </script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head></head>
<body>
    <script src="https://github.com/ethereum/web3.js/blob/develop/dist/web3.min.js" type="text"></script>
    <h1>My Test</h1>
    <div id="output"></div>
    <button id="button">Click</button>
    <script>
        window.addEventListener('load', function() {
            if(typeof web3 !== undefined) web3js = new Web3(web3.currentProvider);
            
            document.getElementById("button").addEventListener("click", function() {
                getMyStringArray();
            }, function(error, result){}, false);
        });

        var contractInstance;
        var contractABI = [{"constant": false,"inputs": [{"name": "newEntry","type": "string"}],"name": "addToMyStringArray","outputs": [],"payable": false,"stateMutability": ","type": "function"},{"inputs": [],"payable": false,"stateMutability": "nonpayable","type": "constructor"},{"constant": true,"inputs": [],"name": "getMyStringArray","outputs": [{"name": "","type": "string[]"}],"payable": false,"stateMutability": "view","type": "function"}];
        var contractAddress = "0x8fcb440a8ba9df8ea91493be3bd27ab562d04386";
<!-- Contract Address is on the Rinkeby Test Network -->
        contractInstance = web3.eth.contract(contractABI).at(contractAddress);


        function getMyStringArray() {
            contractInstance.getMyStringArray(function(error, result){
                document.getElementById("output").innerHTML = result;
            });
        }
    </script>
</body>
</html>
added 62 characters in body; edited tags; edited title
Source Link
Loading
Source Link
Loading