The address provided is incorrect and does not meet the required format

I am facing an issue with initializing the person's address in JavaScript and passing it to a Solidity function. Unfortunately, I keep getting an error related to incorrect formatting.

Here is my JavaScript function:

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

To call this function:

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

And here is the 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++;
    }
}

However, I encounter an error stating "invalid address" after executing this code.

Answer №1

It appears that in the provided code, the contract is missing initialization.

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

Make sure to include the 'from:[address]' attribute in your initialization when sending a contract.

To troubleshoot this issue, consider using browser-solidity or calling this constructor with web3 on a browser. The error occurs at web3.js:3882, so try setting a breakpoint there for further investigation.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Using Selenium with Python to interact with a dynamically generated object that does not have an identifying id or name

Whenever a Right click is performed, an options popup/screen will appear with dynamic content/element. Here is the Options Popup: https://i.stack.imgur.com/TfxpC.png This dynamic content/element will disappear as soon as the mouse is clicked elsewhere o ...

How to properly adjust HTTP headers within an AngularJS factory

Looking for guidance from an Angular expert. I want to know how to modify the header for POST in the code snippet below: 'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8'? The provided code is as follows: var tableMod ...

What could be causing me to receive null when trying to retrieve an element with document.getElementById, even after invoking $(document).ready(function() { ... })?

Here's a small example. I'm feeling a bit rusty with JavaScript, as it's been some time since I last worked with it. The problem I'm encountering is an error in Chrome developer tools: "Uncaught TypeError: Cannot set property 'src ...

Nothing remains after the fall: coding void

I am facing an issue where my item becomes null after being dragged 2-3 times and dropped in a different place. I have included my code below and I can't seem to figure out where the mistake lies. Can you please review it and let me know what needs to ...

Importing arrays from one file to another in JavaScript

Imagine you have a file named file1.js containing an array. var array = [data, more data, ...]; Are there any methods to access this array from another file? If not, what are the typical practices for managing a large array within a file? ...

JSON data is used to dynamically render tables in this process

I have a challenging requirement and I am in search of a dynamic solution to render it. I am reaching out to the experts for assistance with the following requirement. https://i.sstatic.net/VLBd5.jpg I am looking to display the data in the format shown a ...

Examining the appearance of react-hot-toast using jest testing

As I work on my application, I am facing a challenge in writing a test for the appearance of a react-hot-toast. Whenever a specific button is clicked, this toast pops up on the screen and disappears after a brief moment. Despite being visible both on the s ...

Managing form submissions in React with inputs spread across multiple components

I've been working on a ReactJS project with a form that is divided into multiple components. The main component imports all the child components, each containing input boxes, along with a submit button: My issue lies in trying to get all the componen ...

VueJS emits a warning when filtering an array inside a for loop

I'm encountering an issue with my filtering function in VueJS. While it works fine, I am seeing a warning message in the console. You can check out this example to see the problem. The problem arises when I need to filter relational data from a separ ...

Success callbacks parsed from AJAX requests

When dealing with a Backbone object and making an AJAX call to save it, I often wonder about the different ways the success callback can be handled. Sometimes, I see a generic success: function (data) { console.log(data); Other times, it's more spec ...

In Vue/Javascript, once the user reaches the top of the page, automatically scroll down to reveal an extra navigation bar

My goal is to achieve something similar to what is being done on Snapzu.com: When you reach the top of the window, you can keep scrolling to display different categories. I am looking to implement this functionality using Vue or Javascript, but I haven&ap ...

Develop an AJAX script for processing multiple form inputs in PHP and HTML

I am working on a code that involves multiple form submissions, but the submit functionality is not working due to having multiple submits on one page. I have realized that I need an Ajax script to handle this, but I am new to it. Can someone provide me wi ...

What is the best way to organize objects by their respective dates?

I am retrieving data from a database and I would like to organize the response by date. I need some assistance in grouping my data by date. Below is an example of the object I have: var DATA = [{ "foodId": "59031fdcd78c55b7ffda17fc", "qty" ...

data.data for accessing the information in my JSON file

I am having this issue with my factory and controller in AngularJS: 'use strict'; angular.module('testCon').factory('UserService', function ($http) { return { getAll: function () { return $http.get(&apos ...

Executing MySQL queries synchronously in Node.js

When working with NodeJS and mysql2 to save data in a database, there are times when I need to perform database saves synchronously. An example of this is below: if(rent.client.id === 0){ //Save client connection.query('INSERT INTO clients (n ...

I am having trouble accessing the input field in my AngularJS controller

Having an issue with my Ionic framework setup using AngularJS. I am unable to access the input field "groupName" in my controller, as it always returns "undefined". I was under the impression that using ng-model would automatically add it to the controlle ...

Combine multiple values into a single input in the number field

I have a number type input field... What I am looking for is: Age-Height-Weight 20-180-80 Is there a way to ensure that users input data in this exact format and then have the final result inserted into the input field with type="number" and submitted? ...

"Using the selected option from a dropdown list to pass to a PHP file for autocomplete functionality

Although there is no error in the code, I am facing an issue where, after selecting an option from the brands dropdown, when I type in the product field, it passes "%" instead of the brand id (1, 2, or 3). Is there a way to modify the code so that it passe ...

"Unlocking the Power of mediaElementjs: Easy Steps to Accessing the Player Instance

I'm facing a small issue with the MediaElement.js player. To access the player instance, I usually use the following code (which works in HTML5 compatible browsers): // Retrieve player this.playerId = $('div#shotlist-player video').att ...

Angular is encountering an issue where it is unable to read the value of a JavaScript function, despite the object having a value

I have developed some JavaScript functions that involve reading and writing to a JSON file, with the intention of calling them in an Angular environment (from TypeScript code) using the jsonfile library. Below is the code snippet: function savePatient(pa ...