I have some simple ico contracts for airdrop and presale
with lock token future to lock token until ico end
and I want to know how to connect it to token contract
You have 2 way for doing this the first is to create new wallet and put all presale token in the new wallet and then give allowance for the ico contract to controle this wallet and after this do methods for recieve ethers in the contract and transfer from the wallet of presale
Second way is to send the token into the contract and send from the contract token
Related
So I have a token that has about 103 users. What I need to do is restrict the ability to sell those tokens to just myself the developer, so the other users can redeem their tokens for ETH or MATIC by sending to me. The alternative would be to just write a new smart contract, including this function and moving all users to the new platform. How would I write that new contract?
The first, you can't change code of deployed contract in Ethereum.
The second, look at ERC-20 and ERC-721 (NFT) standarts, its already have functionality you need.
I actually need a very simple smart contract using the following functions "transferfrom" and "approve".
I just need a smart contract that will be able to request approval to spend a token ( example -- bake ) from a wallet if the user calls the "approve" function.
It will also be able to withdraw the particular token from the user's wallet to the "address to" set by the contract's onwer, if the onwer calls the "transferfrom" function.
There's a design limitation of the ERC20 standard that disallows approval through a contract in between.
The user always needs to invoke the approve() function on the token contract directly - not through your contract.
I just start to learn solidity and I've finished a couple courses and I want some help to create my first working smart contract.
The smart contract I want to build will buy and sell tokens on the pancakeswap platform from a smart contract; it like my smart contract will start interacting with a pancakeswap contract to execute some trades, doing the same stuff as I'm using their website.
Any help will be appreciated
I have tried to add the interfaces I need to start the interaction between my contract and pancakeswap router contract to use the function
this https://etherscan.io/tokentxns-nft can be a good example of what I would get from Etherscan API, a list with all the transfers related to a specific NFT collection. Moreover, I would include the ETH exchanged for every transfer, a list of target fields below:
Txn Hash
Age
From
To
TokenID
Token
ETH value exchanged in this transfer
is there any API in Etherscan that can let me collect that information?
You can use this API endpoint for Ropsten Network. It will provide you all the details with tokenID and other requirements you listed above.
https://api-ropsten.etherscan.io/api?module=account&action=tokennfttx&address=<your_Contract_Address>&startblock=0&endblock=latest&sort=asc&apikey=<your_API_key>
I am using Ropsten API because my contract is deployed on Ropsten Testnet. You can adjust block with your starting block.
I'm new in solidity and erc20, so I read ERC20 description on the openzeppelin and find this function which isn't clear for me.
approve(spender, amount)
What's the purpose of allowing to the spender spend my token, instead of send my tokens to the spender directly?
You can change the approved amount or revoke it altogether (only the unspent amount). But you cannot take back an already sent transfer.
A common use case for the approve() function is trading on a DEX (decentralized exchange). You approve the DEX contract address to spend your USDT tokens for example. And when you want to buy an XYZ token (against USDT), the DEX simply pulls the already approved USDT from your address and sends you the XYZ tokens.
Approve is a function used to give permission the spender can be anyone an exchange or EOA to withdraw as many times from your token contract up to the _value.
You can check this reference here
As others said, Approve function can give permission to the spender to pulls the amount of token in your address. It can be used in: DEX (decentralized exchange) or in Custody services.
In custody services, after you approve the custody provider to take your token, whenever your wallet receives token, the custody provider is able to transfer your token into some internal wallets and keep them save for you. (It's just like how the traditional banks work)