Bitcoin Forum
April 25, 2024, 01:40:58 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: ICO Transfer without MetaMask plugin Web3js  (Read 183 times)
Alex Brend (OP)
Newbie
*
Offline Offline

Activity: 7
Merit: 0


View Profile
April 26, 2018, 08:09:03 AM
 #1

I want to transfer ICO tokens in test environment from one ETH account to another using Web3js. But it gives service provider not found issue.

It works when I use a local node but not when I use ropsten network.
1714009258
Hero Member
*
Offline Offline

Posts: 1714009258

View Profile Personal Message (Offline)

Ignore
1714009258
Reply with quote  #2

1714009258
Report to moderator
1714009258
Hero Member
*
Offline Offline

Posts: 1714009258

View Profile Personal Message (Offline)

Ignore
1714009258
Reply with quote  #2

1714009258
Report to moderator
Even in the event that an attacker gains more than 50% of the network's computational power, only transactions sent by the attacker could be reversed or double-spent. The network would not be destroyed.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714009258
Hero Member
*
Offline Offline

Posts: 1714009258

View Profile Personal Message (Offline)

Ignore
1714009258
Reply with quote  #2

1714009258
Report to moderator
1714009258
Hero Member
*
Offline Offline

Posts: 1714009258

View Profile Personal Message (Offline)

Ignore
1714009258
Reply with quote  #2

1714009258
Report to moderator
1714009258
Hero Member
*
Offline Offline

Posts: 1714009258

View Profile Personal Message (Offline)

Ignore
1714009258
Reply with quote  #2

1714009258
Report to moderator
devonneburger7
Newbie
*
Offline Offline

Activity: 19
Merit: 0


View Profile
April 26, 2018, 09:46:28 AM
 #2

Are you using Infura?

If not you can run your local node and specify your chain using --chain ropsten
Alex Brend (OP)
Newbie
*
Offline Offline

Activity: 7
Merit: 0


View Profile
April 26, 2018, 10:55:32 AM
 #3

Are you using Infura?

If not you can run your local node and specify your chain using --chain ropsten

I am using infura ropsten and want to use this not local node at the moment. But I do not want to use MetaMask plugin. Is this possible? I am getting provider not found error.
devonneburger7
Newbie
*
Offline Offline

Activity: 19
Merit: 0


View Profile
April 26, 2018, 12:05:43 PM
 #4

You dont have to use Metamask but you will need to sign all your requests or set a defaultAccount.

What is the exact error you are receiving?
Alex Brend (OP)
Newbie
*
Offline Offline

Activity: 7
Merit: 0


View Profile
April 26, 2018, 01:05:26 PM
 #5

You dont have to use Metamask but you will need to sign all your requests or set a defaultAccount.

What is the exact error you are receiving?


I am getting the following error  Invalid JSON RPC response: ""

Here is my code.

Code:
<script>


var Web3 = require('web3');

var web3 = new Web3(new Web3.providers.HttpProvider('https://ropsten.infura.io/875Cngzi6OKdDw19aX8H'));


console.log(web3);

 var OmsCoin = *removed abi*


console.log(OmsCoin);

var address = document.getElementById('address');
var transfer = document.getElementById('transfer');
var disp = document.getElementById('disp');
var tokenAmount = document.getElementById('tokenAmount');

var account = '0x0072c66801e215BffcCd7Aa0A3306dFbb5D05A1B';

var account1 = '0x80198f6f9821775541098b9fC872937e594fC45f';

var decimals;
var token;

    decimals = OmsCoin.decimals.call(function(error,res){
     decimals = res.toNumber();
    //console.log(decimals);
     });


OmsCoin.balanceOf(account, function(error,res){
        token = res.toNumber() / 10**decimals;
        disp.innerHTML= 'Your Token Balance ' + token;
    });
console.log(token);



transfer.addEventListener('click',function(){

/*
OmsCoin.transfer(account1, tokenAmount.value * 10 **decimals, {from:account},function(error,result)
        {
            if(!error)
                  {
                    console.log(tx2 = result);
                    tx2 = result;
                   
                  }
        else
            {
              console.log(error);
            }
        });*/

OmsCoin.transfer(account1, tokenAmount.value * 10 **decimals, {from:account},function(error,result)
        {
            if(!error)
                  {
                    console.log(result);
                   
                  }
        else
            {
              console.log(error.toString());
            }
        });


});


</script>
devonneburger7
Newbie
*
Offline Offline

Activity: 19
Merit: 0


View Profile
April 29, 2018, 09:28:34 AM
 #6

Using web3js you would need to create a custom provider to set the default account.

Using etherJS you can do something like the following:

Code:
const ethers = require('ethers');
const Wallet = ethers.Wallet;
const Contract = ethers.Contract;
const utils = ethers.utils;
const providers = ethers.providers;

let network = "ropsten";
let privateKey = "0x3a1076bf45ab87712ad64ccb3b1021.......";
let infuraAPIKey = "XXXXXX";

let provider = new providers.InfuraProvider(network, infuraAPIKey);

let serverWallet = new Wallet(privateKey, provider);
Quaerat
Newbie
*
Offline Offline

Activity: 1
Merit: 0


View Profile
June 29, 2018, 07:00:44 AM
 #7

Metamask software is the access with the extension of the website visiting to the plug-in device in the metabolism of the visits. I have bridging for the assignmentmasters.co.uk website in the enabling of the accesses to distribute.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!