Using RNDFusion Hub
We are currently Avalanche Testnets and on Sepolia soon!
Create the interface
interface RndFusion {
function RequestRandomNumber(uint256) external payable;
}
Define the interface
RndFusion rndFusion;
Define the interface and contract address
address rndFusionAddress = 0x748E11Bcabdd0aAf06e9618161061E04F417844A;
Set the contract address in the constructor
constructor() {
rndFusion = RndFusion(rndFusionAddress);
}
(OPTIONAL) Create a function to set the address after deployment
function SetRNDAddress(address _address) public {
//Access controll (only owner should be allowed)
rndFusionAddress = _address;
rndFusion = RndFusion(rndFusionAddress);
}
Call the RND fusion contract
rndFusion.RequestRandomNumber{value: msg.value}(requestID);
Create a function for the callback
function fulfillRandomWords(uint256 _requestId, uint256 _randomNumber) public {
require(msg.sender == rndFusionAddress, "Not RNDFusion address");
//Continue with your code using the request ID and random number
}
Testnets
Avalanche Fuji
0x748E11Bcabdd0aAf06e9618161061E04F417844A
Etheruem Sepolia
// Coming soon
Last updated