where to get the address of ether like other token LINK ,USDT - ethereum

Hi I've been trying to create a swapping application as a beginner I'm facing lot of new technical terms and difficultied as well. Now, we have contract address for tokens like LINK[0x514910771af9ca656af840dff83e8264ecf986ca] , USDT[0xdac17f958d2ee523a2206206994597c13d831ec7], USDC[,0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48]., I want to know the address of ether as well or whether layer 1 blockchains have this kind of contract address or not. I'm messing around this since last 3 days.
some clarification on swapping between different network

Related

How can I have users cover the cost of Chainlink's Oracle service in Solidity?

What's the standard way to cover the costs for a Chainlink oracle?
Let's say that I have an NFT mint function that requires the use of external data, or of an external VRF. It costs, say, a fee of 1 LINK. What's the best practice to make the user cover for that cost? (ideally, the best one from both a UX standpoint and a decentralization one)
I see 4 scenarios, all with serious drawbacks:
embedding into the mint function a transfer of amount of LINKs, something like this: require(linkContract.transferFrom(msg.sender, this, amount));. Two issues with this, though: a. you need the user to pre-approve the transfer (linkContract.approve(myContract, amount);), adding one step to the funnel; b. users need to actually have enough LINK in their wallet, which is even more difficult to explain to non-advanced users and makes the funnel even longer
slightly improving from previous point, use ERC677 transferAndCall function: the user calls it on the LINK contract itself, which in turn triggers the mint function by calling onTokenTransfer. Issue: same as previous point, the user needs to have LINK in their wallet - not exactly the best UX
embedding into the contract a logic such that the contract itself figures out on the fly the equivalent of the LINK fee in ETH (using Chainlink's price feeds). The, it "just" require(msg.value == feeEquivalentInEth); - this way, the user only interacts in ETH, and the whole LINK thing would be handled automagically behind the scenes. Issue: need to constantly swap ETH with LINKs, which can lead to either price slippage or(/and) gas costs going ballistic
slightly different from previous point, but still same idea: use LINK meta transaction, where you act as a relay on behalf of the user, cover the costs, and send back an invoice — explained here. Issue: the relay needs to cover for the costs first, and then demand payment back, which is the opposite of a trustless scenario. One could mitigate this by asking for payment first, but gas costs cannot be forecasted easily so not really a solution either.
What's the industry standard? It seems to me highly unlikely that nobody figured this out already, and I'd hate to re-invent the wheel

Solidity : question about ERC20 token creation and pre sales (crowdsales)

I'm working on a new project that I'm launching soon. The dapp is almost ok, I'm writing the contracts.
But I'm not sure I understood everything, if someone can help me :(
I would like to create a token contract with a supply fix (like 1 million), then make two pre-sales (one with and without whitelist), then a contract to sell on DEX with rewards, staking system, etc.
What is the best way to do this?
Is it possible to :
create the tokens with the first contract
transfer them to the pre sale whitelist contract
make the pre-sale
transfer the remaining tokens to the pre-sale contract without withelist
make the pre-sale
transfer the remaining tokens on the last contract, which will manage all the features of my token + put on a dex
am I right in the way I do it or am I completely wrong ?
If I'm wrong, do I have to do everything in one contract, with specific functions and flags like for the beginning and the end of a pre-dirty ?
if I do everything in one, will some smart guy be able to put the contract on a DEX and add liquidity?
I looked for several ohm/nodes project contracts, I saw the pre-sale contracts but I didn't understand when they create the token because their pre-sale contracts are just sell contracts
and I didn't understand how after the pre sale the main contract takes over
i would like a final contract like that, once the sales are finish
https://snowtrace.io/address/0xf2cfc11093edb5a2dc7f49e70a3a3a9cd4f4fee4#code
if someone can help me, thanks :)
ps : last question, in the contract i dont understand what are payees, shares, addresses and balances variables
This question covers a few different things so I'm going to split my answer up.
Answers:
I looked for several ohm/nodes project contracts, I saw the pre-sale contracts but I didn't understand when they create the token because their pre-sale contracts are just sell contracts
Presale contracts by nature are selling contracts the token contract and the presale contract are generally not the same but there are a thousand ways to do that. They receive x amount of tokens and take payment in say ETH for x tokens.
if I do everything in one, will some smart guy be able to put the contract on a DEX and add liquidity?
Anybody will pretty much always be able to add liquidity for a token because that is external to the token but there are certain ways you can prevent adding liquidity until a certain condition is met say a certain timestamp you just need to detect operations that are swaps/adding liquidity and throw an error.
ps: last question, in the contract I don't understand what are payees, shares, addresses, and balances variables
I am not entirely sure what the purpose of these are for because I am not very familiar with the BRIG protocol.
and I didn't understand how after the pre-sale the main contract takes over
The main contract does not need to take over from the presale contract because the presale contract just runs until all of the tokens are sold and then it just becomes an empty husk.
Other stuff:
In the future please split up your questions across multiple StackOverflow posts.

Ethereum Smart Contracts. Could I mask / hide the Contract Creator address and if so, do I need to?

I'm a product manager not a Blockchain coder, looking for a 2nd opinion and some general good practice advice. I have one question in bold, the rest is background.
Background:
We have an app in development that will write user's information into a Smart Contract on the ETH blockchain.
The SC's we deploy contain information only, no Ether.
Each user has their own SC which stores only that users specific information.
Our App allows the user to edit and update this information and then upload the changes, encrypted, into their own SC.
The user's SC address is 'tied' (sorry for lack of correct terminology) to their own Ether wallet.
I see on Etherscan (Ropsten) there is a Contract Creator address which is a constant for all the SC's our App creates.
I'm assuming that the contract creator address is unique to us, it is code we've created and as such it deploys only our Smart Contracts on behalf of our Application.
I was hoping that each SC address would be known only to its owner and us only. Now I see that anyone can access this information.
My Concerns:
Should there be an exploitable flaw in our code then a bad actor has a list of contract addresses to attack.
The worst-case risk to us is that a bad-actor could access each users data in an unencrypted state if a flaw exists in our publicly accessible code.
The Bad-Actor then uses that flaw and the list of smart contract addresses they can get from Etherscan to download multiple users data.
My Question
Are these realistic concerns?
If so what general directions can we look at to mitigate these risks
If so is there a way I can obscure the Creator address in Etherscan without other negative consequences
The developers are outsourced 3rd parties and excellent people to work with. But Im looking for an alternate opinion than just theirs at this time as a double check.
Apologies if the information Ive provided is confusing or incomplete.
Thanks in advance for your time.
I was hoping that each SC address would be known only to its owner and us only. Now I see that anyone can access this information.
As you have addressed here, data regarding the blockchain (i.e. transaction hashes, contract addresses, and user addresses) is transparently available. This is by-design with Ethereum and allows for the traceability aspect of the ledger.
Furthermore, smart contract data is potentially available to any actor in the Ethereum network. However, that is based upon the following:
In order to access the smart contract data, an actor would require the contract ABI. This interface allows code to be written to interact with the smart contract methods. Now, it is helpful to understand that this ABI could hypothetically be easily reverse-generated with enough details of how your DApp interacts with the existing smart contract.
If your smart contract logic has exploitable flaws, a malicious actor on the network could take advantage of this. This is why contracts should be well-written and unit tested with near (if not) 100% code coverage. You should also identify the potential actors in each contract scenario and be sure your test cases appropriately cover these scenarios.
If so what general directions can we look at to mitigate these risks
Given the contract scenario you have described, if the only actor who should have access to these user data smart contracts is the user them self, then you simply need to apply something akin to a function modifier to your smart contract logic. In the linked example, access to the smart contract data is restricted to a single specific Ethereum user address.
If so is there a way I can obscure the Creator address in Etherscan without other negative consequences
Sure. It sounds like you're currently using a single account to deploy the smart contracts, hence the creator address is constant. (Side note: I'm not sure why you're deploying the contract on behalf of the user with this account, it sounds like the user should be deploying their own smart contract). Regardless, you could simply create a new proxy user address each time you deploy the smart contract. However, I don't see any benefit to doing so and this would just be an example of security through obscurity.

What is '0x0' address in Solidity (Ethereum)?

I'm studying solidity programming, and I have a question on this line of code:
Transfer(0x0,msg.sender,tokens);
I don't understand what 0x0 means. Is it the new token address or is it the new smart contract's address?
0x0 is essentially a black hole of an address. Ether funds go in, none come out (kind of like a marriage!). It's an abbreviation for the genesis address 0x0000000000000000000000000000000000000000, which with almost absolute certainty nobody has the private key for, so it can't be spent. Note that tokens like ERC20 can be transferred OUT depending on the contract, but not Ether.
Amusingly/tragically a lot of people screw up and send money here by accident.
In your case, it looks like the contract is trying to send money to this address. Apparently, there's some use cases for this called "proof of burn" which I guess means that you can send ether? I don't quite understand that as it's literally taking Ether out of circulation.
Other cases can be for using it as a large amount for an address for comparison. Example is your_ETH_balance < 0x0 (Is probably TRUE).
Currently, 0x0 has 7251 ether (and growing since I started typing). Today's trading puts it worth about $4.2 million, so it'd be one of the more valuable addresses to crack if you happen to have a functional quantum computer (which you don't).

Working with tokens in the ethereum blockchain

I am writing a test application that allows people to purchase tokens.
I am adapting the example from here: https://ethereum.org/token#the-code
Here are my questions:
What is the best way to have a registry of purchases? I would assume this can be a simple web interface that queries the block chain to see who has bought what.
If this is correct, does this mean running geth on a server in order to have the latest blockchain available and then using some kind of PHP / Javascript library in order to query the blockchain every so often?
What is the best way to sell tokens? Could this be done via a web interface or would it be best to sell via the ethereum wallet? Or both?
Lets say I want to split a token into a number of parts as such:
A: A full token = 1
B: 1/10th of a full token called a 10token
C: 1/10th of a 10token called a 100token
D: 1/10th of a 100token called a 1000token
What is the best way to represent this?
For instance, if someone owns a full token they have 100% of that tokens rights. However it would be possible for many parts of a token to be owned by different people who will share rights according to their share.
Visually, it would look something like this:
How to do this is a puzzle to me.
What is the best way to have a registry of purchases? I would assume this can be a simple web interface that queries the block chain to see who has bought what.
You can do the registry in your token sale smart-contract by making event like this
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
In this case you will be able to watch event log later and get all the addresses you need.
Another approach is to add a simple map to your contract like this mapping (address => uint256) public deposited; and add elements to this map on purchases.
About the representation of the registry for the users you better just take a look at ICO's you like and make it in the same way.
What is the best way to sell tokens? Could this be done via a web interface or would it be best to sell via the ethereum wallet? Or both?
I would say both. But it depends on who are your tokens for. If you sell only using ethereum wallet you will loose a lot of users not familiar with blockchain.
Lets say I want to split a token into a number of parts as such
Take a look at the solutions offered by OpenZeppelin project. Just read their contracts code and I think you'll find solutions you were looking for in this post.