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...
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...
R4Nd0m k0lLEC7I0N 0F U5EFul PHindiN92 0N mY j0URney PhR0m n00b 2 1337. rAmBL1N92 aBoUt 5Ol1d17y, rE4C7, nf7, dEfi, WE83
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...
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...
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
Share Dialog
Share Dialog
<100 subscribers
<100 subscribers
To use chainlink random number generator you need to import 2 contracts localy
import "@chainlink/contracts/src/v0.8/interfaces/VRFCoordinatorV2Interface.sol";
import "@chainlink/contracts/src/v0.8/VRFConsumerBaseV2.sol";
and then you need to have function to request random word(number)
function requestRandomFunction() external {
uint256 requestId = i_vrfCoordinator.requestRandomWords(
i_gasLane,
i_subscriptionId,
REQUEST_CONFIRMATIONS,
i_callBackGasLimit,
NUM_WORDS
);
}
which when called will activate chainlink to provide you with random words in a way that it will call a function called fulfillRandomWords that should look something like this
function fulfillRandomWords(
uint256, /*requestId*/
uint256[] memory randomWords
) internal override {
uint256 indexOfWinner = randomWords[0] % 100;
}
where ChainLink sends a random number to randomWords array, in this example we fetch random number at 0 index in array with
randomWords[0] as Chainlink can send multiple random numbers. In this example we then use that 256 bit number from chainlink to get modulo of 100 from it, which basically picks for us random number less then 100.
This will also not work without subscribing to our contract and adding funds to chainlink so it provides us with this service. For that, we need to setup data in subscription manager https://docs.chain.link/docs/chainlink-vrf/#subscriptions
To use chainlink random number generator you need to import 2 contracts localy
import "@chainlink/contracts/src/v0.8/interfaces/VRFCoordinatorV2Interface.sol";
import "@chainlink/contracts/src/v0.8/VRFConsumerBaseV2.sol";
and then you need to have function to request random word(number)
function requestRandomFunction() external {
uint256 requestId = i_vrfCoordinator.requestRandomWords(
i_gasLane,
i_subscriptionId,
REQUEST_CONFIRMATIONS,
i_callBackGasLimit,
NUM_WORDS
);
}
which when called will activate chainlink to provide you with random words in a way that it will call a function called fulfillRandomWords that should look something like this
function fulfillRandomWords(
uint256, /*requestId*/
uint256[] memory randomWords
) internal override {
uint256 indexOfWinner = randomWords[0] % 100;
}
where ChainLink sends a random number to randomWords array, in this example we fetch random number at 0 index in array with
randomWords[0] as Chainlink can send multiple random numbers. In this example we then use that 256 bit number from chainlink to get modulo of 100 from it, which basically picks for us random number less then 100.
This will also not work without subscribing to our contract and adding funds to chainlink so it provides us with this service. For that, we need to setup data in subscription manager https://docs.chain.link/docs/chainlink-vrf/#subscriptions
No activity yet