Electrum Wallet (Error in signing the message - wallet

when i tried to sign my electrum wallet for byteball transition bot
an error is displayed as
Cannot sign messages with this type of address.
Signing with an address actually means signing with the corresponding private key, and verifying with the corresponding public key. The address you have entered does not have a unique public key, so these operations cannot be performed.
I was using bitcoin address in address and my byteball address in message. How can I solve this problem? Any help is greatly appreciated

Related

How to get the address who is paying the gas (Sending the transaction)?

I have an usecase of rewarding the user who is actually sending the transactions and paying the gas for the transaction.
As we know msg.sender returns the address from which the call came but, when the contract is called from another contract, msg.sender returns the called contract address. But in this case i need address of the user who has actually sent the transaction.
mapping(address=>uint256) public txSender;
function test() public {
address _txSender = getTxSender();
txSender[_txSender]++;
}
function getTxSender() public view returns(address) {
return msg.sender;
}
getTxSender not always returns actual user who is signing the tx.
You can access the original sender in the tx.origin global variable.
Mind that using this variable for authorization is considered as a vulnerability.
So if you need to use the original sender address for authorization, you should pass the msg.sender from the first contract - through the chain of internal transactions - to the final contract receiving the information.

Can an ethereum smart contract address hold many types of tokens?

I know that an ethereum funds address can hold many types of tokens. If the address is a contract address, can it also hold many types of tokens? or it can only hold the token it defines?
In other words, is it true that any address in ethereum can:
have at most one smart contract attached to it. This allows other users to locate this smart contract.
have arbitrary types of tokens attached to it. The address here allows other smart contract to keep track of the balance this address owns.
^ Is this correct? Thanks.
Both your assumptions are correct.
I'll just clear out the fact that it's not the "owner" address holding the tokens per se. The information which address owns how many tokens (or which tokens, in case of NFTs) is stored on each token contract. Also, blockchain explorers (such as EtherScan or BscScan) aggregate this data in their off-chain databases, so it's easier to search on their site.
Example:
Contract 0x123 (token ABC) holds the information that Address A owns 1 ABC token.
Contract 0x456 (token DEF) holds the information that Address A owns 2 DEF tokens.
A blockchain explorer has all this info aggregated in their off-chain DB, so that users can simply filter "all tokens by Address A" and they don't have to keep querying all token contracts asking "How many of your tokens does Address A own?".

How does a User account own an ERC20 Token

This question is a little conceptual, so hopefully this picture will help clear up my misunderstanding.
Image there is a crowdsale smart contract deployed on address 0x2. A User at address 0x01 buys a token.
Here is my understanding of what happens:
The crowdsale contract (# address: 0x2) accepts ether from the user account (# address: 0x1)
The crowdsale contract stores 0x1 as having purchased a token (important: this information is stored in the smart contract #address 0x2)
Now my Question: If 0x1 is a user account (and not a smart contract) there is no code at address 0x1. I thought a user account just consisted of an address + ether associated with the address, how can it also store the fact that 0x1 owns an ERC20 token? For example, I can login to MetaMask and (before clicking the "add token" option) MetaMask can see that I have a token... how is this possible?
Every ERC20 contract has the following function:
function balanceOf(address _owner) public view returns (uint256 balance) {
return balances[_owner];
}
Your wallet just calls this function from the known token contracts with your address. Since it's a view function it doesn't cost any gas.
I recon most ERC20 token get added rather quickly to a wallet like Metamask or MEW. But if your balance doesn't automatically show, you can add the contract address manually (in MEW at least, not sure about Metamask) and it will show up afterwards.
In solidity there are two ways to get the address of the person who sent the transaction
tx.origin
msg.sender
In your example, in the method inside ERC20 Token.sol, the value tx.origin will be 0x1 and msg.sender will be 0x2
So to answer your question, how does the ERC20 token know about 0x2 is: it depends on how the token contract is written and whether it uses tx.origin or msg.sender. I would imagine it uses msg.sender, because that is the more prevalent one.
If it does use msg.sender you can still make the crowdsale contract work by first buying the tokens and then immediatelly transfering the tokens from the crowdsale contract to the caller.
For more information, refer to What's the difference between 'msg.sender' and 'tx.origin'?
how can it also store the fact that 0x1 owns an ERC20 token?
Token transfers, or transfers in accounting in general, are kept in a ledger. In this case, the ledger is ERC-20 smart contract that internally keeps balances who owns and what in its balances mapping. Or, the smart contract manage the storage (EVM SSTORE instructions) where the records of ownership are kept.
Note that some other blockchains, like Telos and EOS (and mayne Solana) might be opposite and there the storage is maintained on the user account (user account has associated RAM and tables for any token user owns).

How to create custom wallet for ERC20 tokens

I know metamask, MEW etc can be used, but how can I create a new wallet for an ERC20 token.
Having [NAME-OF-TOKEN Wallet].
Can generate new token address on sign up automatically.
Can send tokens from one address to another without having ETH deductions, unlike Metamask etc.
Hope to hear from anyone with answers, suggestions or links soonest.
Thank you!

Generate new ethereum address

I'm currently working on a ethereum dapp where users can login and perform transactions. I'm a newbie in dapp development. The problem is I've been trying to make something happen which is when a user registers the dapp, a wallet address will automatically be generated for that user. Any help will be appreciated
An account on Ethereum is nothing but holding a private key.
There are many software packages like web3j (for java), web3js (for javascript) which help in creating private keys and accounts.
To create a private key, you need to input a string. This string will be sent to a one-way hash function. Since private keys have to be unique for every account, the input string has to be random. Few standard practices would be using the (current time stamp + user mail id + password + random phrases) as the input string.
Once you create a private key for a user, you can generate an account for him.
Hope this helps.