New answers tagged

2

I'm not quite sure why you would want to use a centralized server handling the tokens for the users. I'm not sure I quite understood your use case. Just to make sure we're on the same page: typically users are in control of their tokens (through their private key) and the role of centralized server is simply to for example query balances and other data from ...


2

As you mentioned this really defeats the whole purpose of building and running dApps. If you want an example of centralized you can look at xHumanity(https://xhumanity.org/) project which I worked on and built a bridge between ethereum and binance smart chain. Which essentially is a centralized server that burns and mints tokens on the respective chains and ...


0

You can implement a mint function in your contract to mint the tokens to the desired address or list of addresses. You can try this approach to schedule function calls: Can you call a contract function via a cron job?


1

You can not have a function with the same name as an event. The convention is to capitalize the first letter of an event. e.g. Transfer instead of transfer


0

GasFees only charge in Ether. On the Ethereum blockchain, gas refers to the cost necessary to perform a transaction on the network. Miners set the price of gas based on supply and demand for the computational power of the network needed to process smart contracts and other transactions.


0

You need to enable mainnet forking in Hardhat network to be able to access a copy of mainnet-deployed contracts in your local running instance. You could enable mainnet forking with the following Hardhat config: const config = { networks: { hardhat: { chainId: 1337, forking: { enabled: true, url: `https://eth-mainnet....


0

you want to transfer an ERC20 token in a smart contract, either the contract holds the token, or the contract has been authorized by a wallet to call its ERC20 token!


0

How about doing it more passive way, like whenever you buy a new token you can give allowance to the smart contract with a higher value(mostly the tokenSupply of the token) and later the beneficiary address can call a function in the smart contract to transfer these tokens directly from your wallet to their wallet.


1

ERC-20 tokens actually do not have fractions, but internally use 256-bit words for accounting. It is just convention that we set the decimal point on 10 exp 18 on this number, to communicate with humans. So you can transfer a fraction of tokens by just calling transfer() with a number that is less than 10 exp 18.


0

You could do the following: const ethers = require('ethers'); const genericErc20Abi = require(..../.../Erc20.json); const tokenContractAddress = '0x...'; const provider = ...; (use ethers.providers.InfuraProvider for a Node app or ethers.providers.Web3Provider(window.ethereum/window.web3) for a React app) const contract = new ethers.Contract(...


0

Please look at the Contract-name.json in build/contracts folder and find pragma solidity in the file content. That shows you the correct compile version. If you get the compile version, please check if the publish page's compile version is equal to that. Sincerely hope this would be helpful to you.


0

Change you LP token name in file located at /src/pages/RemoveLiquidity/index.ts search for domain object: const domain = { name: 'Spooky LP', // <= here place your LP token smart contract name version: '1', chainId, verifyingContract: pair.liquidityToken.address, }


1

The concept of whitelisting is something that is custom-built. Yes, there exist some templates for the functionality, but in the end it simply depends on how you implement it. If you add whitelisting to token transfers, then the token can't be transferred unless you are in the whitelist. The tokens don't disappear anywhere, they appear in the user's wallet ...


0

Since no one answered this simple question I'll do it. For new comers, what you have to use is a bridge. For example Binance has a bridge to convert ERC20 to PEB2 tokens, the bridge is made by the Blockchain devs, for example Polygon has another bridge to convert Tokens from the ETH blockchain to theirs.


0

You can check this working example with my token: https://github.com/religion-counter/onlyone/blob/main/helper-scripts/send-onlyone.js Also you can contribute to the repo if you are interested. // Helper script that sends ONLYONE token to target addresses specified in targets.txt // Target index - index in targets.txt file is specified as an argument - ...


0

Not unless that contract supports Erc20 withdrawal in it's implementation, which is a very slim chance of it being the case. You could read more about that here.


2

There is two different address in Ethereum. The one controlled by a private key (usable for a user). Smart contract that are address controlled by a code (no private key). If you didn't put a function to handle ERC20 token in your contract, they are lost for the user that send ERC20 token. You can handle token with a "safetransfer" function that ...


0

Yes but Is someone sends the token say, 10000 to the liquidity pool and sets the price. In swap only 10000 are available for people to buy. How can people buy more than that. Do you need to add liquidity again or can you sell it from your wallet directly without putting it into the liquidity pool and putting equal amount of other currency as liquidity.


1

Use Metamask or truffle-hd-wallet-provider for creating address.You can create 'n' no of address


0

In order to use onlyOwner modifier the contract should inherit from Ownable. import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v2.5.0/contracts/ownership/Ownable.sol"; contract CresstCrowdsale is ..., Ownable { function setEndTime(uint _endTime) public onlyOwner notFinalized { require(_endTime > ...


0

No.Contract can't change its byte code once it has been deployed.


0

No, it is not possible since the ERC-20 standard doesn't have such functionality. It should be possible to have an off-chain part that tracks Transfer events and the forwards a message to the contract. Another thing you should consider is that there are tokens like AMP whose balances change without emitting events.


0

The transaction in your example is masked, so I can't really tell, but it does not look like a Contract Creation transaction. The first transaction that you see on a contract page is the Contract creation transaction. The to address is the contract's address. The from address is the address of whoever deployed it. Here is an example (the USDT contract ...


0

Here you can find an example of such a smart contract. https://blog.infura.io/build-a-flash-loan-arbitrage-bot-on-infura-part-ii/ Nothing unusual here. Just do a call to different smart contracts in a single transaction.


1

Founder of Sablier here. You have not been scammed, the "immediate transfer" you're talking about is just how our protocol works (we transfer the money from one contract to another one). GSWAP is using Sablier to stream the LP tokens to you - think of this like vesting shares but in DeFi fashion. We have a FAQ that explains what money streaming is. ...


0

This is usually done to create a token pair in Uniswap. It is needed for the token to allow the tokenPair some privileged actions like rebalancing liquidity for example.


1

The transaction will be a change in a mapping from the smart contract. Each entries cost gas as it's described on yellow paper : https://ethereum.github.io/yellowpaper/paper.pdf Page 25. If you "mint" a token, I think it modify an entry on mapping as : address 0x000000 mint X tokens. If someone transfer token, you will add token to another address ...


0

You can fork the contract and do a bridge that give you 65% of your tokens with a burn function. But it will cost gas for everyone, because rewrite an entire mapping is quite expansive. There is no easy way to do it, and none where it's free. You will either pay for the redistribution (in eth) or your user will.


1

You're right that not specifying decimals, would treat it as 0. It sounds tautological, but to answer your related questions, a totalSupply of 100 would be 100 tokens, and a transfer of 10, would transfer 10 tokens. When using decimals, make sure to see this question because it does affect the values for totalSupply and transfer amounts: Decimals on ERC20 ...


0

The transfer() function does not care if there are decimals or not. It is purely a cosmetic divisor for human display.


0

This was already answered in Hardhat's discord, but in case anyone ends up here... The problem is that the mint function was overloaded. That is, the contract had two implementations of that function with different signatures: contract Foo { function mint(uint amount) public { ... } function mint(uint amount, address to) public { ... } } When this ...


0

Well, if you want them to create their own NFT on "your" ERC-1155 token , you can. Actually, you create a contract that enable them to drop the Metadata, their address, pause and burn their asset, then mapping all of these. But perhaps one contract for all of that is not enough: 1 contract to create the NFT 1 contract to deal with the NFTs of your ...


1

The problem is that op has to call approve, not the contract addresses. let pancakeContract = new ethers.Contract('0x05fF2B0DB69458A0750badebc4f9e13aDd608C7F', pancakeABI, ethers.getDefaultProvider()); let wbnbContract = new ethers.Contract('0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c', wbnbABI, ethers.getDefaultProvider()); it('Retrieving LP token pair', ...


2

In PR #2669 where those changes were made they mention Issue #2665. In that issue a comment by vladyan18 points that using unchecked reduces gas usage at deployment by 1723.


-1

In order to cross blockchains you need to send a transaction through a bridge. For example to send a transaction from Ethereum to Polygon you need to send the Matic Network Bridge. This takes about 10 min to complete https://wallet.matic.network/bridge/


0

I think the question is wide open and I am not sure if I get it right but I will tell you how I think a payment process should work for e-commerce using crypto: 1- You use Metamask's JS to connect to Metamask, same for each wallet. 2- You only use one single ETH address to collect all payments. (Not sure if you really need more than 1 due to your business ...


0

I had some experiences with the function you are using, and as far as I gather. It is impossible to allow others (other addresses) to spend your/user tokens. The approve() function here, is instead used to verify the amount of tokens you wish to transfer by using transferFrom() Example: You have 1000Tokens on address1 and wish to transfer 100 to address2 ...


0

50,00,000 For clarity, I'll assume you meant for 50,000,000. With two decimal places, add two more zeroes, so: 50,000,000.00 => 5000000000. You still have the problem of indivisibility/precision at the low end, e.g. sending 1. This just doesn't go away. You can and should decide what happens to rounding errors because they are unavoidable. Hope it helps.


0

You could deploy your own custom router contract. Easily fork one from the original Uniswap Router. Make every write function to be onlyOwner(). Then modify the swap function so instead of sending the token back to the sender wallet. The contract itself will receive and send the token. Thus when selling you don't need any approval, because the contract is ...


Top 50 recent answers are included