contract has an function "addToWhiteList", only owner of the contract can access this function and add user in whitelist.
/**
* @dev Adds single address to whitelist.
* @param trusted Address to be added to the whitelist
*/
function addToWhiteList(address trusted) public onlyOwner {
require(!whitelist[trusted]);
whitelist[trusted] = true;
emit UserWhitelist(true);
}
I am trying to add the user on whitelist from owner account :
// Send Transaction to the Blockchain
function sendTransaction() {
const functionAbi = Contract.methods.addToWhiteList("0x9DA80947ACf5Fc16299311EdAabc37fF7d201C95").encodeABI()
console.log(functionAbi);
var nonce = web3.eth.getTransactionCount("0x61A44075419C4402f6DE631341d875Ece6A3922e");
var gasPrice = "2";//or get with web3.eth.gasPrice
var gasLimit = 3000000;
var ownerPrivateKey = "0x5c9c7e00edc09d0df072c0de7911026a4ab241aa8a5e9f063fb450ba91fbc360";
var formatedPrivteKey = ownerPrivateKey.substring(2);
var tx = new ethereumjs.Tx({
nonce: web3.utils.toHex(nonce),
gasPrice: web3.utils.toHex(gasPrice * 1e9),
gasLimit: web3.utils.toHex(gasLimit),
to: ContractAddress,
value: '0x00',
data: functionAbi
});
tx.sign(ethereumjs.Buffer.Buffer.from(formatedPrivteKey, "hex"));
var raw = "0x" + tx.serialize().toString("hex");
web3.eth.sendSignedTransaction(raw)
.on('receipt', function(receipt) {
console.log(receipt);
}).on("error", console.error);
}
Note : Add web3 : web3 1.0
Init. web3 :
web3 = new Web3(new Web3.providers.WebsocketProvider("wss://ropsten.infura.io/ws"));
user is not adding in whitelist when i use console of the browser and call the function "sendTransaction" from console :
sendTransaction()
undefined
when i check
Contract.methods.isAddressWhiteList("0x9DA80947ACf5Fc16299311EdAabc37fF7d201C95").call().then(console.log);
it's return false
May 18, 2018, 9:08 AM
hmm..
how can we send signed tx, ?
@pablocryptobar010
no, firstly I craete some dapp and then I start setup proovate chain on my local and now I am learning
I know the a Dapp is not an ico.
not doing anything in ico.
JUst trying to make a web3 connection to one ico contract.
JUst trying to make a web3 connection to one ico contract.
leave it..
I don't want tp do any argu. with you
@migumar , now I always ask some tricky questions
which takes some efforts.
which takes some efforts.
ya !! I completed crypto zombies chapters
any solution or advise for my issue ?
okay thanks
man, not intrested in doing ico.
just want to learn
May 18, 2018, 9:45 AM