Send ERC-20 token using Web3j - ethereum

What is the best way to send transaction in Ethereum with ERC-20 token and get balance of account using web3j

Take a look at https://github.com/blk-io/erc20-rest-service it will proxy requests into an ERC20 contract.

Related

When sending some custom ERC-20 tokens to the other accounts, is the other accounts received fewer tokens?

When sending some custom ERC-20 tokens to the other accounts, is the other accounts received fewer tokens?
I send my custom ERC20 tokens to the other account on solidity 0.15 the custom tokens. (150000000000000000 Wei)
However, The other account received only 149999997646012400 Wei.
Was it works well?
I think the other account must have the same amount of custom tokens and the sender needed to pay native tokens like ETH, and BnB tokens as gas for that.
What am I getting wrong information?
Thank you in advance.

Can you make an ERC1155 contract receive an ERC721 token?

I've got an ERC1155 contract and I want it to receive an ERC721 token and give other tokens in exchange for that. Can I somehow add ERC721 Receiver interface?
Yes you can do that. It would be best to start looking here at OpenZeppelins documentation on it: https://docs.openzeppelin.com/contracts/2.x/api/token/erc721#IERC721Receiver
In your method that accepts ERC721 tokens, you will need to make sure that the sender approves your contract to transfer tokens on their behalf or else the transaction will fail.
In conjunction with IERC721Receiver you have to use the safeTransferFrom method for this to work properly.
hope this helps.

How to approve Token to self-deployed contract

My ultimate purpose is to swap some tokens across pancakeswap babyswap apeswap atomicly. So I build a contract(called ContractA) to run a bunch of swaps in a transaction. I transfer some USDT token into ContractA. But ContractA is not approved to transfers USDT by the USDT contract.
I known how to approve Metamask address to transfer USDT, but how to do it for a Contract?
In order to control an ERC20 token from a smart contract, first you need to create an instance of it. To do that, first you need to import ERC20 to your contract, and then just create an ERC20 type function giving it the token address you want to manage. It would be something like this:
// Some code...
import "#openzeppelin/contract/token/ERC20/ERC20.sol";
// Some more code...
contract exampleContract {
// Example of an ERC20 token instance
ERC20 USDTToken = ERC20("USDT Contract Address Here");
// Approve USDT
USDTToken.approve(address(this), _amount);
}
Then you will be able to manage the token, always following the ERC20 standard, as you want.
Hope you find this information useful :)

How to get gas fee to send erc20 token at mass volume?

I am learning node JS developing a crypto currency exchanger as a homework project where user can deposit ERC-20 token and Ethereum. I am generating unique ethereum deposit address for every user, where they can deposit ERC-20 token and ethereum. but after sometime I want to move the received ethereum and ERC-20 token to another address (cold wallet).
If someone only send ERC-20 token to the address and no etherum, then how I'll get ethereum to pay as gas fee to transfer the received ERC-20 token to cold wallet?
If suppose, I am first paying etherum (for gas fee) from cold address to the user address, and then using that etherum to transfer received ERC-20 token, will it work at mass level ? means if 10000 users do the same thing at the same time, will not it create a problem ? or is there any better solution for this?
If there's no eth in that account, you can't take the ERC-20 token out.
Transfer some eth to the address and then get ERC-20 token out is the only way. The problem is how to save the gas as far as you can.
You can write a batch transfer contract to send eth to several hundred addresses in one go (the ceiling is determined by block gas limit), batch transfer saves gas. Then you can collect the ERC-20 tokens.
Of course, you can charge your user for compensation.

Developing USDT wallet on ERC20 tokens

I am new to the Ethereum network. I want to develop a wallet (on JavaScript and Node.js) for USDT based on the ERC20 token on the Ethereum network.
Can it be built on JavaScript and Node.js?
Also USDT is a tether-based cryptocurrency whose value is about equal to US$1. So for example, USDT on the ERC20 network works on Ether addresses. So if I send 1 ETH to that address then will it be automatically converted to current ETH value to USDT? (i.e, approximately 273$)?
I am learning Ether on Ether's documentation, so do I need anything else to learn and create a USDT and ETH wallet?
Yes, it can be built using JavaScript and Node.js.
And if you send 1 ETH (US$273) to some other address, you will receive 1 ETH, not 273 USDT. The value is not converted automatically. You'll have to exchange your 1 ETH against 273 USDT.