Can Ethereum contract execute transactions directly on Bitcoin? - ethereum

Can an Ethereum contract execute transactions directly on the Bitcoin network? Ethereum contracts must be pure functions without any external side effects, and committing a transaction on another blockchain would be an external side effect, so I would assume this is not possible. What options would be possible for this sort of scenario?

Can an Ethereum contract execute transactions directly on the Bitcoin network?
Not directly. Ethereum and Bitcoin are two separate networks with different architecture and without any "official" bridge.
However, I could imagine a wild scenario that involves creating a BTC transaction based on Ethereum transaction:
User makes a transaction to an Ethereum address
An external app is listening to incoming transactions to this Ethereum address. When it learns about the new (Ethereum) transaction, it creates a BTC transaction object, signs it and broadcasts it to the Bitcoin network.
It's based on the way how some oracles work. They are listening to incoming transactions containing instructions, fetching some off-chain data (based on the instructions) and sending a new Ethereum tx that passes the off-chain data to a smart contract.

Related

If RPC node crashes in private Ethereum network, transactions in mempool might be lost?

In a private Ethereum network, transactions get submitted to the network via a single RPC node. If the RPC node crashes at some point, is there a possibility of loss of transactions that are in its mempool and haven't been propagated yet to the other nodes? Since mempool is in node memory, after RPC node recovery those transactions are supposed to be lost permanently from the network?
If the RPC node crashes at some point, is there a possibility of loss of transactions that are in its mempool and haven't been propagated yet to the other nodes?
Yes.
Until you 1) receive a block with your transaction 2) are sure about the fact that the network has accepted this block, you cannot know if your transaction is propagated or included in the chain.

How to transfer coins from a newly created wallet(s) to the central one in an automatic manner, once a wallet has received some coins?

I'm working on a project in which there'll be users and wallets. A user will sign up and my service will
a) generate a new address - wallet - and assign it to him, in a database
b) each user will be ablt to top up his wallet
c) there'll be one central admin wallet
d) once a user wallet has been topped up, the service or TRON network will should transfer the coins in it to the central admin wallet
How will it be better to implement the functionality that will send coins, right away, from a user's wallet to the central admin one?
Simply polling the balance of each user wallet? There're maybe be tens of thousands wallets - too expensive to poll each one, every minute.
How else?
Alternatively, if I used only the central wallet and users sent their funds directly to the centrall wallet, would there a way to track each user's deposit?
It'll be TRON network. However, I've added "Ethereum" as well in case there's no difference for this task in terms of implementation.

How to check if ETH transaction was ever sent

I'm creating a transaction with web3.eth.accounts.signTransaction. I'm then storing that transaction hash, then sending it over the ETH network with web3.eth.sendSignedTransaction
How do I programmatically check if a signed transaction was or wasn't sent yet over the network yet? I'm not interested if it was mined, confirmed or rejected - I just want to check if it was ever sent or not.
How do I programmatically check if a signed transaction was or wasn't sent yet over the network yet?
When you create a transaction, you get a transaction hash. With this transaction hash, you can query its status using eth_getTransactionByHash JSON-RPC API.
After you see your transaction being mined in the first block. because the probabilistic nature of proof-of-work network, you need to wait few blocks to ensure that the Ethereum blockchain chain tip does not reorganise. Then you can use status flag of the receipt field to determine if the transaction was reverted or not.

Can the Ethereum network be used as a database

Can we use the Ethereum network just like a database to store data. What might be the possible issues that can occur if it is used as a database.
Yes, it's possible. Just write a smart contract to store and retrieve your data.
Google the term "Solidity CRUD" for articles and tutorials for storing data in on Ethereum.
The downsides are:
Speed - Blockchains are slow to write and not fast to read. Ethereum will never be able to compete with even low performance databases like SQLite much less go against Postgres, Oracle or MongoDB.
Cost - Reading from Ethereum is free but writes cost Ether. The exact cost depends on the size of the data you want to store. For small amounts of data this does not matter much. For services you can even make this part of the API that your users will pay writes (such as buying a ticket form you) so it doesn't cost you anything. But if you have gigabytes of legacy data migrating it to the blockchain can be very expensive.
On top of that, doing large data transfer to the blockchain will see demand for transactions spike which will increase the cost per transaction. This is not just theoretical, it has happened before - when the cryptokitties smart contract was launched the game suddenly became so popular that transactions went from less than one cent per transaction to tens of dollars per transaction (USD).
In general you'd want to store only the core data that you need to be secure on Ethereum and link it to other data sources (for example store a URL link and hash of the object but store the object itself on Amazon S3 or Azure Storage)

how to store data in eth blockchain without gas

I want to create an app where I store some data/text in the Ethereum blockchain, I know it's possible with smart-contracts but is there a way to store without paying gas?
Thanks!
No, you have to pay gas because this is essentially data that every person who is running a node must store on their computer