How can I make smart contract non-upgradeable - smartcontracts

Is there a way to make a smart contract NON-upgradeable on Near?
By default I can always overwrite a contract at an account address. This is different from Ethereum where after deployment the contract gets a new address after which it is by default non-upgradeable.

Contract can be locked by removing the full-access key:
https://docs.near.org/develop/deploy#locking-a-contract

Related

It is possible to change BEP-20 smart contract code?

I have deployed a contract on the BEP-20 network and now I don't need mint and owner address transfer functionality.
So I want to remove these options from the "write contract" options list.
If it is possible if yes then what can I do?
Smart contract bytecode is immutable. Assuming that your contract is not a proxy but a regular contract - you cannot change the already deployed code.
After you've made the changes in your local code, you'll need to recompile it, and deploy to a new address.

How to change old implementation contract address on etherscan?

I wrote upgradable smart contract using solidity and upgraded contract several time.
When I upgraded smart contract, implementation contract address was changed.
But under that address, the old implementation contract address still remains.
https://rinkeby.etherscan.io/address/0x245dBBE31f33569D3d7F1e0df10c93547c44065D#readProxyContract
How to change or hide this old address?
Particularly you can't hide anything once it is stored on the Blockchain. The old address will still be visible.
But if you want that calling to the old contract should fail, you can simply create a self destruct function inside your smart contract and call it when you have updated the smart contract and deployed it with a new address.
Tip -
Always have smart contracts with the self destruct functionality
Whenever you update your smart contract i.e deploy it to a new address, call the self destruct function on the old contract address for it to be destroyed.
Syntax for self destruct -
contract YourContract {
// State variables
// Some functions
function destruct(address addr) ownerOnly {
selfdestruct(addr);
}
// The above function sends all ether from the contract to the specified address
}

ERC721 Smart contract revoke approval

I've some question about ERC721 processing. I'd like to make an user to give aproval to an external smart contract for transfering one of its NFT.
To do it I'm using approve(to, tokenId).
Then, in some situation, the contract should be able to revoke its own autorisation by calling approve(address(0), tokenId)
(The NFT owner calls a cancel method from the smart contract that perform some operations and revokes its own permission on the token)
At this step, I got the following error:
ERC721: approve caller is not owner nor approved
My understanding is that in order to make the contract able to call approve, the NFT owner should have approved it with setApprovalForAll(operator, _approved)?
What about others NFT from the same collection owned by the user ? Would the contract be able to manage them too ?
I'd like to limit as much as possible the smart contract's permissions and stick to a very specific NFT transfer (with its token_id)
Can someone enlighten me on the right way to do it ?
It sounds like you have 2 contracts and an EOA involved in this process. You want the NFT contract to give another contract permission to transfer tokens, as well as remove that permission. You should be following this order:
1.) EOA calls approve(to, tokenID) on the NFT contract
2.) NFT contract has a function that calls approve(address(0), tokenID)
3.) Non-NFT contract calls the function in step 2
--> rever error
You would indeed get this error if Non-NFT contract has not been given approval permission for tokenID. Even though the token owner is calling that function, the context of the call reads the Non-NFT contract address as msg.sender. You could avoid this actually if the function inside the Non-NFT contract made a delegatecall instead of a regular call.
You do not need to use setApprovalForAll if you are only working with one NFT. You can give the contract approval by calling approve() and then revoke it with the method you stated above.

Migrate my users ERC1155 tokens to ERC721

I have my ERC1155 token contract deployed on Ethereum network
i want my token holders to make the token to 721 standard and burn the old tokens
how can i achieve that using a proxy contract
need some proper direction on this , thanks
So looking to migrate the OpenSea ERC1155 tokens to the new ERC721 tokens. The existing contract has 135 tokens.
a proxy contract won't let you do this migration for a couple of reasons, first a proxy contract just let you update the address of the contract where the actual logic is, but it has some limitations, like that the proxy contract should be deployed from the beginning you can't just deploy a proxy an expect that it changes or modify an existing contract, but let's say you have an upgreadable erc1155, for the limitation of the proxy you will probably have a lot of problems doing this update, because you can't change the way that the variables are defined or stored, you can't delete any existing function (you can leave it empty instead),and other things
probably you will need to deploy a new contract that will be the erc721, then you will have to make another contract that makes the swap, receive a token from the old contract and gives the token of the new contract, is on you how the contract will get the new tokens if it will mint the tokens or if it will have it, also you have to considere what you will do with the old tokens because if the old contract do not let the tokens to be burned you can't, but you could lock it in the same contract or something similar that is almost the same as burning it

How much nfts can be transferd on 1 smart contract?

I can't figure out if i need to Deploy a smart contract for each transfer? or can 1 smart contract serve several transactions? Thanks ahead
You don't need to deploy another smart contract to transfer NFTs.
Info about each token ownership is stored in its collection contract. So you just need to execute the safeTransferFrom() function on the collection contract from the current owner address, passing it following params:
current owner (_from)
receiver (_to)
token ID (_tokenId)
There are several ways to execute the function from a regular (non-contract) address, for example using the UI of EtherScan/BSCScan under the Contract -> Write Contract section on the detail page of the collection contract address.
Note: All assuming the collection contract follows the ERC-721 standard.