my question is basically written in title, but for more details, I am using node.js, I read immutableX documentation and review there SDKs, but nothing on javascript,
I want to sign the transaction in cloud function(firebase) on immutableX chain.
Main goal is to transfer ERC20 tokens from one wallet to another. In my case, token which I want to transfer is GODS.
Thanks!
Well, I've never used ImmutableX but I think that for transferring ERC20 tokens you can use any library that can interact with Ethereum contracts like web3js
https://piyopiyo.medium.com/how-to-send-erc20-token-with-web3-js-99ed040693ce
Related
I'm new in blockchain development, I wonder why is it necessary to interact with contract from another contract instead of from a personal EOA address?
Besides the delegatecall, I can't imaging any advantage to use contract to call another deployed contract's functions. As a user, I may rather use ethers or web3js through wallet etc to interact with a deployed smart contract instead.
would you please show me some reasons or necessary cases that I should design my project using a smart contract to interact with another smart contract? Thanks a lot!
There are too many use cases:
1- Upgradeable contracts or proxy contracts. Since blockchain technology is evolving so fast, it is so hard to write a contract that will be scalable. With proxy contracts, user calls the proxy contract but proxy calls the main contract. if in the future you have to change the logic of the contract, you deploy a new contract and make the proxy contract call this new contract. This way users will not get affected. You can read more about this pattern here
2- If you ever need to get data from real world, you cannot make an api call because this is not safe and not deterministic. for this reason, we use oracle services which also calls to many other smart contracts behind the scene, gets the results from each, and make a final response to the user. You can read more about oracles here
3- another use case is factory contracts. think about it as a class and users keep make an instance of it. that way instead of factory owner pays for the new contract creation, user will be paying for the deployment. you can read more about factory contracts
4- defi platforms have too many smart contracts and they are interacting each other. They keep the logic separate from each other, so they maintain better and see the missing points better. also putting everything in one contract would make contract code is bloated and make a mess. you can read uniswap
5- another use case to deploy library smart contracts. those are usually mathematical contracts which are deployed once and once u need complex functionalities, instead of you implement in your contract, you use library contracts and use them in your project. You can read about libraries
6- another use case is solving the scalability issues. imagine you have one kitchen and you have to serve all the customers from only one kitchen. As you get more customers, your service will eventually halted. so, there are layer 2 solutions to transfer some of the orders to different kitchens. and this of course happen through smart contract communications. more on layer 2
7- In general you can use inheritance. You deploy some contracts and inherit the logic from those smart contract. that is why you see openzeppelin contracts always inherit from each other
For example there are some standarts in Ethereum ecosystem. ERC20, ERC721, ERC1155 and others. So when you developing new project, instead of writing it from scratch you could install openzeppelin-contracts, import them and inherit. Afterwards you have this "carcass", on the top of which you can implement some additional functionality/custome code, etc. That approach is way more convenient and secure.
Another great example chainlink-contracts. Via them you can read from oracles. Oracles are smart contracts that keep track of cryptocurrencies prices online. Say you want your users to pay 10$ to participate in lottery/some giveaway. Your contract interacts with chainlink contract and makes sure that amount of eth that user paid is greater or equal to 10$ otherwise it returns error.
In solidity there is no true randomness, but again throughout interacting with chainlink contracts we can reach it. Another chainlink feature is automation contracts, check chainlink documentation to learn more(https://docs.chain.link/). To sum up id say that there is a lot of different protocoles/concepts which easier to interact with than to write it again.
"No need to reinvent the wheel"
Is it possible to transfer ERC-721 tokens from multiple wallets to a single wallet in one transaction? If not, is there another quick way? I'm interested as I mint a lot of tokens (50+) to multiple wallets, and want to merge these all into one wallet quickly. What kind of a smart contract would I need to write for this?
Is it possible to transfer ERC-721 tokens from multiple wallets to a single wallet in one transaction?
No it's not possible. You can always write your own ERC-721 token contract that supports such functionality. Normal NFTs do not desire this functionality as it only makes bot minting easier and bot minters is something the community does not tolerate.
Is it possible in Solidity for a smart contract to be able to interact with a specific wallet in such a way that it can pull money from it, and send money to it at any time it needs to? In this particular scenario, there will be a treasury wallet, that I want the smart contract to be able to pull from and send to at any time it needs to. Is this something that's possible with a few approvals, or perhaps is there a better, more standard way to resolve the problem that I'm having?
The treasury wallet needs to do ERC-20 token approve() on the specific wallet and then it can pull money.
For further details, check out EIP-20 spec.
I need some assistance. I am working on a smart contract that will allow a user to save a string (mapping(address=>string)). The only problem, I would like the contract to pay for the gas for the user to save the string. Any idea on how to
This is a proposed feature but not yet implemented: https://github.com/ethereum/EIPs/issues/1776
This feature is known as meta-transaction: the sender of the transaction doesn't pay for gas.
While there is no native way to conduct meta-transactions yet, there are third-party efforts to implement it, searching the web with meta-transaction keyword should yield useful stuff.
Have a look at the Gas Station Network Alliance:
https://blog.zeppelinos.org/gas-station-network-alliance/
Depending on your use case, if you don't need to save strings directly on chain, an alternative would be something like Peepeth - microblogging with a soul. Peepeth batches signed messages stored in IPFS and anchors the batched data on chain: https://peepeth.com/a/free
I am studying blockchain with Ethereum, and I want to use past transaction data in the Smart contract using Solidity.
If I use Web3.js module in the program written in javascript, I can get these data easily.
But I can't get these data in the Smart contract using Solidity.
Reference of Solidity says that we can get current block number, blockhash, etc., by using "block.number" and "block.blockhash(uint blockNumber)" functions, but doesn't mention getting transaction data.
(http://solidity.readthedocs.io/en/latest/units-and-global-variables.html#special-variables-and-functions)
please help me.
The answer is simple. Unfortunately, you simply can’t access old transaction or block data onchain from Solidity. At most, you can access hashes of last 256 blocks (see blockhash in documentation )
Alternatively, as a workaround you could consider using Oraclize. Oraclize represents way to read offchain data onchain, so you could try to read transaction data from Etherscan web API. The way Oraclize works is that :
You request to Oraclize smart contract what data you want to fetch from internet (some URL)
Oraclize offchain servers then detect your on-chain request
The look up the data you wanted (they'll make some http request to the URL you provided)
Once they get response, they will send transaction to your contract (calling specific callback method) containing data you requested
With such approach however, you are relying that:
EtherScan is up and running
Oraclize is up un running.
If you only care about transaction data related to your smart contracts, another way would be to store that transaction data onchain. Maybe we could gave you some more suggestions if you tell us more about what specific problem are you solving.