Skip to content
This repository has been archived by the owner on Feb 11, 2024. It is now read-only.

How to switch account without using metamask? #4

Open
fransicoA opened this issue Apr 14, 2021 · 0 comments
Open

How to switch account without using metamask? #4

fransicoA opened this issue Apr 14, 2021 · 0 comments

Comments

@fransicoA
Copy link

I am new to Ethereum, I am developing a voting app following this example: https://github.com/dappuniversity/election

I want to create a new account and give private keys to users so they can cast their votes using their private keys. When I am switching accounts from Metamask, [msg.sender] account address also changes. I want to switch the account without Metamask so [msg.sender] can also change the account address. How can I achieve it? I don't want to switch the account address from Metamask.

function vote (uint _candidateId) public {
require(!voters[msg.sender]);
require(_candidateId > 0 && _candidateId <= candidatesCount);
// record that voter has already voted
voters[msg.sender] = true;
// update candidate voteCount
candidates[_candidateId].voteCount ++;

I am using Truffle v5.1.4, Solidity v0.5.12, Web3.js v1.2.1, and Ganache
https://i.stack.imgur.com/2UArz.png

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant