Hello team,
is there a way where i can sell my bnb in my account and get bsc-usd on chain. my simple aim is i will be getting bnb and after some time this shoul be sold and the bsc should be credited back to my account on a function call,
everything should be on chain via solidity,
Thanks,
Jun 26, 2022, 4:09 PM
Contract wallet + keepers should do the work
Jun 26, 2022, 4:10 PM
any sample code please
Jun 26, 2022, 5:01 PM
it will be custom code as per your need. Although you can see chainlink docs for implementation.
https://docs.chain.link/docs/chainlink-keepers/introduction/
https://docs.chain.link/docs/chainlink-keepers/introduction/
Jun 26, 2022, 5:02 PM
import "@chainlink/contracts/src/v0.8/KeeperCompatible.sol";
contract XXXXX is KeeperCompatibleInterface {
uint256 keepersEnabled = false;
uint256 keepersInterval = 1 days;
uint256 lastTimeStamp = block.timestamp;
function checkUpkeep(
bytes calldata /* checkData */
)
external
view
override
returns (
bool upkeepNeeded,
bytes memory /* performData */
)
{
upkeepNeeded = (block.timestamp - lastTimeStamp) > keepersInterval;
// We don't use the checkData in this example. The checkData is defined when the Upkeep was registered.
}
function performUpkeep(
bytes calldata /* performData */
) external override {
//We highly recommend revalidating the upkeep in the performUpkeep function
if (
keepersEnabled &&
(block.timestamp - lastTimeStamp) > keepersInterval
) {
// YOUR LOGIC THERE
}
// We don't use the performData in this example. The performData is generated by the Keeper's call to your checkUpkeep function
}
contract XXXXX is KeeperCompatibleInterface {
uint256 keepersEnabled = false;
uint256 keepersInterval = 1 days;
uint256 lastTimeStamp = block.timestamp;
function checkUpkeep(
bytes calldata /* checkData */
)
external
view
override
returns (
bool upkeepNeeded,
bytes memory /* performData */
)
{
upkeepNeeded = (block.timestamp - lastTimeStamp) > keepersInterval;
// We don't use the checkData in this example. The checkData is defined when the Upkeep was registered.
}
function performUpkeep(
bytes calldata /* performData */
) external override {
//We highly recommend revalidating the upkeep in the performUpkeep function
if (
keepersEnabled &&
(block.timestamp - lastTimeStamp) > keepersInterval
) {
// YOUR LOGIC THERE
}
// We don't use the performData in this example. The performData is generated by the Keeper's call to your checkUpkeep function
}
this is my code on my project, on mainnet working fine :)
Hi
Jun 26, 2022, 5:09 PM