0

I am trying to deploy my code to Infura network i compiled and i got no errors but now when i am trying to deploy i am getting error

const HDWalletProvider =  require('truffle-hdwallet-provider');

const   Web3 =  require('web3');

const { interface , bytecode } = require('./compile');

//const inter = require('./compile');


const provider =  new HDWalletProvider(
  'timber belt sem',  // my memonic
  'https://rinkeby'   // my test network 
);

const web3 = new Web3(provider);

const deploy = async() => {
  const accounts = await web3.eth.getAccounts();

  console.log("Atemting to deploy the contracts from " , accounts[0]);

   const result  = await new  web3.eth.Contract(JSON.parse(interface))
   .deploy({ data: bytecode , arguments:['','']})
   .send({ gas:'1000000' ,from : accounts[0]});

   console.log("your contract is deployed to", result.options.addres);


};

deploy()

Getting following error

 Atemting to deploy the contracts from  1.1112838411420756e+48
        (node:28660) UnhandledPromiseRejectionWarning: Error: Provided address "1.1112838411420756e+48" is invalid, the capitalization checksum test failed, or its an indrect IBAN address which can't be converted.
            at Object.inputAddressFormatter (/home/mdvenkatesh/Desktop/etherium solidity programes/hotelbooking/node_modules/web3-core-helpers/src/formatters.js:409:11)
            at Contract.getOrSetDefaultOptions [as _getOrSetDefaultOptions

    ] 

My solidity code

pragma solidity ^0.4.17;

contract hoteltranscation  {

    struct hotel{
        string HotelName;
        uint256 BookingNumber;
    }

    hotel[] HotelBookings;

    function HotelBooking(string _HotelName, uint256 _BookingNumber) public   {
        HotelBookings.push(hotel (_HotelName, _BookingNumber));
    }

    function GetHotelBooking(uint _num) public view returns(string, uint256) {
        return (HotelBookings[_num].HotelName, HotelBookings[_num].BookingNumber);
    }
}

deploy code correctly for my previous code but now i can't use it

dependeces

 mocha ganache-cli web3@1.0.0-beta.26
  • It looks like your accounts[0] data is getting mangled or otherwise converted to an integer (hence the 1.1112838411420756e+48). The thing is, it doesn't appear to be caused by anything in your code--unless this isn't your full code. Could you console.log() the accounts object just before the "attempting to deploy" log line and post back with the output? – Motoma Oct 25 '18 at 16:25
  • ok i will update once it is done – md venkatesh Oct 25 '18 at 16:29
1

Make sure that deploy parameters are right, from, data parameters should be strings in hex format with 0x prefix.

let contract = new web3.eth.Contract(JSON.parse(abi)));

await contract.deploy({data: '0x' + bin, arguments: contractArgs})
    .send({gas: 2310334, from: accounts[0]});
  • i have changed the gas it successfully deployed could you help with two things 1) how to leave gas default without specific 2) after deploying it is showing your contract is deployed to undefined – md venkatesh Oct 25 '18 at 16:46
1

which version of truffle-hdwallet-provider are you using? If you are using the new version of web3, you need a different version of the provider. This is what I have in my package.json for one of my projects using new web3:

"truffle-hdwallet-provider": "^1.0.0-web3one.0"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.