Solidity javascript Wrong format invalid address

0 votes

I hava a problem. I need to initialize the person having the address of the purse in the Javascript, then pass it to the function Solidity, but I get an error about wrong format.

My JavaScript function

 $scope.myToken = accounts[0];
 $scope.initProviders = function(providersAddresses,providersAmount){
  alert(providersAddresses);
  contract.init(providersAddresses,providersAmount,$scope.myToken).call();
 };

And call this function

<md-button ng-click="initProviders('0x199fdf564df1d18056ed46724582502fd3ce580a',1)">INIT</md-button>

And Solidity code

function init(address[] provAddrs, uint provCount,address mainAcc)
{
    clientAddr = mainAcc;
    for(uint i = 0;i<provCount;i++)
    {
        providers[i].profit = 0;
        providers[i].addr = provAddrs[0];
        provCount++;
    }
}

But after that I have error invalid address

Sep 17, 2018 in Blockchain by slayer
• 29,370 points
1,297 views

1 answer to this question.

0 votes

The contract lacks initialization, at first.

var contract = eth.contract([abi])
                     .new([array of params], 
                     {data:'0x...', from:[address], gas:47000, gasPrice: 37891200});

I think this should work

answered Sep 17, 2018 by digger
• 26,740 points

Related Questions In Blockchain

0 votes
1 answer

Solidity invalid opcode error

In the for loop, your indexing going ...READ MORE

answered Aug 16, 2018 in Blockchain by slayer
• 29,370 points
3,080 views
0 votes
1 answer

Bitcoin address SHA256 pipe gives wrong output

You need to hash the raw byte ...READ MORE

answered Sep 5, 2018 in Blockchain by digger
• 26,740 points
840 views
0 votes
1 answer

Invalid opcode error in a simple Solidity contract and script

You don't need to call .at() if you're using .new(). ...READ MORE

answered Sep 14, 2018 in Blockchain by slayer
• 29,370 points
4,853 views
0 votes
2 answers
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
1,942 views
+1 vote
3 answers

Removing double quotes from a string from JSON response in PHP

Just remove the json_encode call, and it should work: $resp ...READ MORE

answered Sep 12, 2018 in Blockchain by digger
• 26,740 points
45,296 views
0 votes
1 answer

How do I add multiple recipients for transactions via Blockchain API?

Convert the recipes into JSON objects. x = ...READ MORE

answered Jul 6, 2018 in Blockchain by Perry
• 17,100 points
924 views
0 votes
1 answer
0 votes
1 answer

How to get all address and send ethers in solidity using a loop?

I found a similar code somewhere: contract  Holders{ uint ...READ MORE

answered Jul 31, 2018 in Blockchain by digger
• 26,740 points
2,768 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP