Ethereum contract code visualization - ethereum

I am using Ethereum with testnet Rinkeby, I created a contract and deployed it. Is there a way to display the source code of that contract? I know that contact are immutable but I want just to have a look on the code.

There is currently no way to do this and probably will not be for a while, because the code is not published on the blockchain, just the byte code from the compilation. There are certain block explorers that can help like ether.camp that you can upload solidity code to then it can check against a given address to see if it matches. There is also a project that is scraping git to find the source code to match byte code.
http://etherscrape.com/about
So no once the code is deployed there is no easy way to see it.

Related

Meaning of "Minting an NFT" and OpenSea.io question

I have some questions regarding NFT and hope someone can clarify it for me:
Here are what I have done so far: I've successfully run through the whole process of
Uploading an image to IPFS,
Deployed a ERC1155 contract in remix,
Mint an NFT and
Successfully showed it in opensea.io
Here are my questions:
What does it truly mean by "Minting an NFT"? As far as I know, does it mean I create a token (NFT) that represents that uploaded image?
What is the role of "Minting an NFT"?
What are the differences between "Minting an NFT using smart contract" vs "Uploading an image to opensea.io and sell it"?
It seems to me that they are the same. When I mint an NFT using smart contract, opensea.io will create a new collection for me with that contract, and the result is the same when I create a collection manually and upload an image to sell.
When I create an image and upload to IPFS, I also tried manually creating a metadata.json file to describe that file and upload it to my Google drive, which is accessible via URL.
Then when I run the smart contract, I use that meta file link as a parameter to mint an NFT.
My question is: the whole process actually did not mention "opensea.io", why opensea.io knows that I am running a smart contract and create a collection for me? '
Hope someone can help clarify that for me.
Thank you very much in advance for all your help.
What does it truly mean by "Minting an NFT"? As far as I know, does it mean I create a token (NFT) that represents that uploaded image?
Correct. Minting a token is a term used for creating the token.
What are the differences between "Minting an NFT using smart contract" vs "Uploading an image to opensea.io and sell it"?
When you upload an image to OpenSea a create a new sell order, they can currently do one of two things depending on the options you chose:
Mint a token in their own collection contract right away
OR
Mint a token in their own collection contract when the sale is successful
why opensea.io knows that I am running a smart contract and create a collection for me?
They are listening to Transfer() events on collection addresses registered in their system. Or query the historic events when you add the address later.
When the event is emitted, they can create a record in their own database pointing to your token in your collection contract, effectively creating an OpenSea collection page (not a collection contract) and filling it with your token details.

Export contract address and ABI from Ethereum Remix

For a number of reasons, Ethereum Remix is great for developing in Solidity. However, I need to integrate what I develop there into some other Web3 front end stuff. So after each time I deploy a smart contract in Remix I have to copy and paste the contracts address as well as the ABI into another IDE so it can interact with the Web3 frontend.
Is there some sort of way to do the step of copying the contract address and ABI from Remix into a text file on my local system? I couldn't find a Remix API. Was wondering if anyone has another idea.

My fork of Uniswap will not show my liquidity pools

How to recreate problem:
Go to this build...
https://gateway.pinata.cloud/ipfs/QmYv2TAkFNcDGG5jj9TT4G2qpVubgVP2NgHNoqn2wB71CR/build/#/swap
*DO NOT USE THIS IN MAINNET-ONLY RINKEBY
Click on the "pool" tab on the navbar after connecting your web3 enabled wallet such as metamask (make sure that your network is set to rinkeby, I only deployed contracts to that testnet!), and create a pool by clicking on "add liquidity" or "create".
The interface should let you go through with the transaction so make sure you have some test ETH on hand. The contracts created from that transaction will produce "Sushi LP Tokens"(Again not real ones, that just what I set the name to be so that it would be easily recognized.)I made sure to replace all of the contract addresses precompiled in the frontend interface with my own contracts that are listed below, even the uniswap/sdk mods.
The problem that I am having specifically is that the pool doesn't show up on the list of pairs in the modal as it usually does if you have used uniswap before. The strange thing is that it will show pools that I created on the live uniswap site using the rinkeby network.
I even created an init code hash just as instructed in this tutorial:https://blockchain.news/wiki/how-to-build-an-uniswap-exchange
I apologize in advance if this is not the correct way, place, or time to ask for help, but here I am, I am willing to work with anyone that knows how to set this up correctly.
Github:https://github.com/DarriusAlexander/uniswap-interface
My reputation is not very high so please refer to this reddit post that I created to get the contract address and metadata links.
https://www.reddit.com/r/ethdev/comments/n0hegy/please_helpi_forked_uniswap_for_a_personal/

How to deploy a contract from BSCScan onto the Binance Smart Chain?

as most of the BEP20-Tokens-Contracts are online available on GitHub or BSCScan you should be able to just copy the code and paste it into remix.ethereum.org and deploy it. I did that and the contract deployed successfully to the BSC but the token information are missing. What do I do wrong?
Here is the code I copied: https://bscscan.com/address/0x0cF011A946f23a03CeFF92A4632d5f9288c6C70D#code
and here is my contract deployed to the BSC: https://bscscan.com/address/0xf5be6f7f00a4870b46f3ab6d16f5095731da97d7
I have just changed the name of the token, but the token information are not showing up on BscScan nor do I see the token in my Wallet. Any help is appreciated!
Your contract's bytecode contains just the Address contract bytecode. Since it's the first contract in the list (sorted alphabetically), I assume you simply forgot to select the contract that you wanted to compile.
You need to select the NyanCatToken contract (which effectively imports the Address as well) when compiling in Remix.

Upgrading smart contract in ethereum

I am trying to write upgradable smart contract in ethereum. Can anyone give an example of upgradable smart contract in ethereum and accessing data.
To write an upgradable smart contract I suggest you do the following (works for me):
Create a storage contract on which you will store all your map and variables. Add a modifier to the functions changing state. This modifier should require that an address must be present in a specific map (let’s call it authorized) to change the state of map or variable. Place the owner’s address in that map.
Write a function to authorize external address on the storage contract
Deploy another contract containing the logic of your app.
Autorise the logic contract on the storage contract.
Upon upgrade of the logic, deny access to the storage contract from the logic contract, deploy your upgraded logic and link the new contract to the storage.
Tadaa you now have an upgradable set of smart contracts.
Smart Contract cannot be replaced, but you can create a smart contract proxy to be able to replace the calling of all new Smart Contract functions (previous smart contracts cannot be removed on the main network ethereum).
Complete explanation and examples can be seen Here
You can implement follow Proxy Pattern
Blog
https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357
Smart contract upgradability is a state of the art area. Currently, there are a few solutions, but each of them has its own pros and cons. Here are the solutions with examples:
https://consensys.github.io/smart-contract-best-practices/software_engineering/