Hot answers tagged

2

To add to goodvibration's answer, the problem with sending ERC-20 to any contract is that the contract is not aware of that transaction. There's no function that's called when the tokens are received, so it's not possible to assign that balance to a specific sender. This is why things like decentralised exchanges use approve and transferFrom. In this case a ...


2

Think I found the answer actually: Call a smart contract payable function sending erc20 token User/me first needs to call the approve function in the LINK contract then my Remix contract can transfer tokens from msg.sender to itself itself using LINK's transferFrom function.


2

how do we register user in smart contract You're struggling to find this description because the task is already done for you, depending on what you mean by the process of "registering". get the userdata when he/she tries to login after register through our website This is full of hidden assumptions and ambiguities. who/what gets the userdata? ...


2

To receive ERC20 payments you usually use the combination of user's approval and transferFrom from the contract. User calls token's approve function with the recipient contract address. Using a wallet, perhaps Metamask. In javascript it will look like: token.approve(recipientContactAddress, amount, { from: userAddress }); User calls a function from the ...


1

In general, ERC20 token transaction is completely different than ETH transaction. If transaction occurs between two contracts, for a ETH transaction the receipt contract must have fallback function in its code. Also, the sender must have fallback function in its contract code. Whereas, an ERC20 token transaction does not need any fallback function neither in ...


1

That is a poorly worded comment. It should read: Create a table so that we can map the addresses of token owners to those who are allowed to utilize the said owner's tokens. This lets you whitelist someone else to use your tokens. For instance, you can allow me to spend 10 of your tokens. So, with .approve, you save in the mapping: you => me => 10 ...


1

I'm not sure where you found that example but there are multiple issues with it: It's old. That version of Solidity shouldn't be used in new projects anymore The comments in it do not make sense so just ignore them It has a bit of weird code Perhaps the best and most widely-used modern implementation is from OpenZeppelin at https://github.com/...


1

Sure, but the flow is a little counter-intuitive and takes some getting used to. You can send ETH and/or data to a contract function. The data can instruct a contract function to seize a certain amount of a token from someone, usually the msg.sender (but not necessarily). Your contract would use the ERC20, transferFrom(<funder>, <amount>) ...


1

pragma solidity ^0.7.0; contract Wallet { address private owner; constructor () payable { owner = msg.sender; } receive () external payable { // Do nothing } function execute (address payable _to, uint _value, bytes memory _data) public payable returns (bytes memory) { require (msg.sender == owner); (bool success, bytes ...


1

Do you know the MultiSender app? It allows for multiple Ether and ERC 20 token transactions to be bundled in one transaction. It's open-source on Github rstormsf/multisender in case you want to review the logic. There's also a more detailled write-up on Medium: MultiSender — Send Ether and Ethereum Tokens to Multiple Ethereum Addresses In A Single ...


1

As far as I know its not possible. You can call another contract (B), with your contract (A) as sender, but you can't act as someone else. With delegate call, you use the function of another contact (B) in the context of the caller (A). So it is like copying the code of the function from B to A. I guess it is impossible by design, because otherwise a simple ...


1

Blockchain doesn't care if there are hundreds of tokens with the same name and abbreviation. However, Nasdaq, in this case, is a crypto exchange and no exchange would list two tokens with the same name. So it is in the project's best interest to have a unique name that won't make confusion.


Only top voted, non community-wiki answers of a minimum length are eligible