Skip to content

[Error] Cannot deploy contract onto Testnet #2146

@ghost

Description

What I am doing

I am trying to deploy smart contract onto testnet shasta. But whenever I try to deploy a contract it always shows OUT_OF_ENERGY error.

Expected Behaviour

Contact should be deployed successfully onto Testnet.

Actual Behaviour

When I try to migrate a smart contract using tronbox it shows below error.

ERROR: Contract Election has not been deployed on the network.
For more details, check the transaction at:
https://api.shasta.trongrid.io/wallet/gettransactionbyid?value=1deabb8330f39f6a153781fb7e3ce83c2ba2c31914e14d5d99fc37db95e20038
If the transaction above is empty, most likely, your address had no bandwidth/energy to deploy the contract.

Even if I have enough energy for deploying the smart contracts.

This is the configuration that I had added in the tronbox.js file.

shasta: {
      privateKey: 'edec2a9abe800b8f71288cb0315b682e8257f2c7553a3503cae7b4a362cd787f',
      consume_user_resource_percent: 100,
      fullNode: "https://api.shasta.trongrid.io",
      solidityNode: "https://api.shasta.trongrid.io",
      eventServer: "https://api.shasta.trongrid.io",
      network_id: "*"
    }

And this solidity contract code that i want to deploy in the test network.

pragma solidity ^0.4.25;

contract Election{

    struct Candidate{
        uint id;
        string name;
        uint voteCount;
    }
    mapping (uint => Candidate) public candidates;
    uint public candidatecount;
    mapping (address => bool) public voter;

    event eventVote(
        uint indexed _candidateid
    );

    function addCandidate(string _name) public {
        candidatecount++;
        candidates[candidatecount] = Candidate(candidatecount,_name,0);
    }

    function vote(uint _candidateid) public {
        require(!voter[msg.sender]);
        require(_candidateid > 0 && _candidateid <= candidatecount);
        voter[msg.sender] = true;
        candidates[_candidateid].voteCount ++;
        emit eventVote(_candidateid);
    }

}

Any help would be highly appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions