Example of implementation of EIP 4906 metadata updates
EIP 4096 has an interesting method of updating your metadata with events, more details here. https://eips.ethereum.org/EIPS/eip-4906 So lets see how to implement it with an example. First you need to create a file with interface that has this code in itpragma solidity ^0.8.0; import "@openzeppelin/contracts/utils/introspection/IERC165.sol"; /// @title EIP-721 Metadata Update Extension interface IERC4906 is IERC165 { /// @dev This event emits when the metadata of a token is changed. /// Third-...

How to get Uniswap V3 liquidity pool address for whitelisting?
Similar to what we did for Uniswap V2 on how to find address of smart contract pool that will be generated we can do the same for V3 https://mirror.xyz/n00b21337.eth/0QkNt3NnLnnUSy4jFmWnaeRr_38Z3wlYKKf1O6URG3c Depending on what chain we are at, you can find all the addresses of Factories here https://github.com/Uniswap/sdk-core/blob/5365ae4cd021ab53b94b0879ec6ceb6ad3ebdce9/src/addresses.ts#L135 Aim for the v3CoreFactoryAddress values.**So there are a few methods to do that, one could be to us...
Clear browser storage when developing
Different wallet scripts usually use window.localStorage for saving data for reuse and determination of what is the status of wallet connect, sometimes this could be awire and you need to clear it, you could delete all in browser like cookies, stored data and all the rest but you can also call first this in consolewindow.localStorage to check what is saved and then you can delete it all withlocalStorage.clear(); orlocalStorage.removeItem("name of localStorage variable you want to remov...
R4Nd0m k0lLEC7I0N 0F U5EFul PHindiN92 0N mY j0URney PhR0m n00b 2 1337. rAmBL1N92 aBoUt 5Ol1d17y, rE4C7, nf7, dEfi, WE83
If you are using Truffle and want to install it globally with NPM but having some permission errors like permission denied, open '/root/.config/truffle/config.json' you can use unsafe and allow root parameters to achieve that, like with the line below
sudo npm install -g truffle --unsafe-perm=true --allow-root
You will need to update your truffle-config.js configuration file to include the following:
module.exports = {
...
solc: {
settings: {
optimizer: {
enabled: true,
runs: 1500
}
}
}
}
To deploy contracts from start but not compile them we can use yarn truffle deploy --reset --compile-none --network live
To make dry run and you dont want to deploy contracts yarn truffle deploy --dry-run --reset --network live
To reset migration state on network where you canceled transaction you need to reset it. This is because truffle remembers previous migrations you made but you are on a new test network. You can see registered contract addresses by running truffle networks.
You can delete these information by running truffle networks --clean before truffle migrate.
The easiest way to get compiler version with truffle is to find it in your project directory ./build/contracts/YourContractName.json near the bottom of the file. It looks like
"compiler": {
"name": "solc",
"version": "0.7.18+commit.9cf6e910.Emscripten.clang"
}
I tried to upgrade truffle and install new version but I kept getting some kind of errors like
An unexpected error occurred: "https://registry.yarnpkg.com/truffle: getaddrinfo EAI_AGAIN registry.yarnpkg.com"
and just couldn't upgrade truffle to latest version. What helped is that I used yarn cache clean and then resolved the problems I was having. But some other solution would also be to change the registry of yarn. If you run command yarn config get registry you would probably get https://registry.yarnpkg.com some people say they change it to yarn config set registry https://registry.npmjs.org and that helped with fetching proper repos.
After running truffle console --network rinkeby you can use below line to check if contract address is deployed, you would get bytecode returned if it is
web3.eth.getCode("0x0de378AbDB252E1d63Cd3d956343E76640F720Ed", function(err, code) { console.log(code);})
When I run some script in truffle console with "exec" it would finish but would be stuck and no ctrl+d or +c could unstuck it, I needed to close the terminal window and reopen it. To solve this I needed to put process.exit(); in a script so what I ended up with was something like this.
const checkURI = await nftContract.methods.tokenURI(1).call(function(err, res){
console.log(res);
process.exit(0);
});
First to connect to network of your choice add flag to console truffle console --network rinkeby After that make an instance of deployed contract with let instance = await myContract.deployed() and then you can call functions like some getters or setters on contract instance.baseTokenURI()
You can also use console to get quick estimates of gas used for functions, so you run instance.lazyMintAdditional.estimateGas(600,700) and you will get estimate for function lazyMintAdditional with parameters 600 and 700. or to get estimate of contract creation, you will need to run contract name with NEW method and constructor parameters in parenthesese like Creature.new.estimateGas("0xf57b2c51ded3a29e6891aba85459d600256cf317")
getting current price of Gas web3.eth.getGasPrice(function(error, result){ console.log(result)})
getting current balance of added account to network settings let balance = await web3.eth.getBalance(accounts[0]);
get nonce of current wallet var firstNonce = web3.eth.getTransactionCount(yourSender)
If you are using Truffle and want to install it globally with NPM but having some permission errors like permission denied, open '/root/.config/truffle/config.json' you can use unsafe and allow root parameters to achieve that, like with the line below
sudo npm install -g truffle --unsafe-perm=true --allow-root
You will need to update your truffle-config.js configuration file to include the following:
module.exports = {
...
solc: {
settings: {
optimizer: {
enabled: true,
runs: 1500
}
}
}
}
To deploy contracts from start but not compile them we can use yarn truffle deploy --reset --compile-none --network live
To make dry run and you dont want to deploy contracts yarn truffle deploy --dry-run --reset --network live
To reset migration state on network where you canceled transaction you need to reset it. This is because truffle remembers previous migrations you made but you are on a new test network. You can see registered contract addresses by running truffle networks.
You can delete these information by running truffle networks --clean before truffle migrate.
The easiest way to get compiler version with truffle is to find it in your project directory ./build/contracts/YourContractName.json near the bottom of the file. It looks like
"compiler": {
"name": "solc",
"version": "0.7.18+commit.9cf6e910.Emscripten.clang"
}
I tried to upgrade truffle and install new version but I kept getting some kind of errors like
An unexpected error occurred: "https://registry.yarnpkg.com/truffle: getaddrinfo EAI_AGAIN registry.yarnpkg.com"
and just couldn't upgrade truffle to latest version. What helped is that I used yarn cache clean and then resolved the problems I was having. But some other solution would also be to change the registry of yarn. If you run command yarn config get registry you would probably get https://registry.yarnpkg.com some people say they change it to yarn config set registry https://registry.npmjs.org and that helped with fetching proper repos.
After running truffle console --network rinkeby you can use below line to check if contract address is deployed, you would get bytecode returned if it is
web3.eth.getCode("0x0de378AbDB252E1d63Cd3d956343E76640F720Ed", function(err, code) { console.log(code);})
When I run some script in truffle console with "exec" it would finish but would be stuck and no ctrl+d or +c could unstuck it, I needed to close the terminal window and reopen it. To solve this I needed to put process.exit(); in a script so what I ended up with was something like this.
const checkURI = await nftContract.methods.tokenURI(1).call(function(err, res){
console.log(res);
process.exit(0);
});
First to connect to network of your choice add flag to console truffle console --network rinkeby After that make an instance of deployed contract with let instance = await myContract.deployed() and then you can call functions like some getters or setters on contract instance.baseTokenURI()
You can also use console to get quick estimates of gas used for functions, so you run instance.lazyMintAdditional.estimateGas(600,700) and you will get estimate for function lazyMintAdditional with parameters 600 and 700. or to get estimate of contract creation, you will need to run contract name with NEW method and constructor parameters in parenthesese like Creature.new.estimateGas("0xf57b2c51ded3a29e6891aba85459d600256cf317")
getting current price of Gas web3.eth.getGasPrice(function(error, result){ console.log(result)})
getting current balance of added account to network settings let balance = await web3.eth.getBalance(accounts[0]);
get nonce of current wallet var firstNonce = web3.eth.getTransactionCount(yourSender)
Example of implementation of EIP 4906 metadata updates
EIP 4096 has an interesting method of updating your metadata with events, more details here. https://eips.ethereum.org/EIPS/eip-4906 So lets see how to implement it with an example. First you need to create a file with interface that has this code in itpragma solidity ^0.8.0; import "@openzeppelin/contracts/utils/introspection/IERC165.sol"; /// @title EIP-721 Metadata Update Extension interface IERC4906 is IERC165 { /// @dev This event emits when the metadata of a token is changed. /// Third-...

How to get Uniswap V3 liquidity pool address for whitelisting?
Similar to what we did for Uniswap V2 on how to find address of smart contract pool that will be generated we can do the same for V3 https://mirror.xyz/n00b21337.eth/0QkNt3NnLnnUSy4jFmWnaeRr_38Z3wlYKKf1O6URG3c Depending on what chain we are at, you can find all the addresses of Factories here https://github.com/Uniswap/sdk-core/blob/5365ae4cd021ab53b94b0879ec6ceb6ad3ebdce9/src/addresses.ts#L135 Aim for the v3CoreFactoryAddress values.**So there are a few methods to do that, one could be to us...
Clear browser storage when developing
Different wallet scripts usually use window.localStorage for saving data for reuse and determination of what is the status of wallet connect, sometimes this could be awire and you need to clear it, you could delete all in browser like cookies, stored data and all the rest but you can also call first this in consolewindow.localStorage to check what is saved and then you can delete it all withlocalStorage.clear(); orlocalStorage.removeItem("name of localStorage variable you want to remov...
Share Dialog
Share Dialog
R4Nd0m k0lLEC7I0N 0F U5EFul PHindiN92 0N mY j0URney PhR0m n00b 2 1337. rAmBL1N92 aBoUt 5Ol1d17y, rE4C7, nf7, dEfi, WE83

Subscribe to N00b21337

Subscribe to N00b21337
<100 subscribers
<100 subscribers
No activity yet