Hey does anyone have an idea about how to create a automatic script
When I receive bnb in a wallet I want that bot to transfer it to other wallet automatically
Dec 8, 2021, 2:54 AM
can any one help me with this please ?
Hey does anyone have an idea about how to create a automatic script
When I receive bnb in a wallet I want that script to transfer it to other wallet automatically (please help!)
When I receive bnb in a wallet I want that script to transfer it to other wallet automatically (please help!)
Dec 9, 2021, 3:56 PM
you mean you need a contract that receives BNB and transfer it to just one address?
Dec 9, 2021, 3:57 PM
No , what i need is i have a wallet which got compromised ,so when ever i receive some bnb to this wallet i want that bot or script to send that bnb to my another wallet automatically
Dec 9, 2021, 4:01 PM
i don't see how possible that will be.
Dec 9, 2021, 4:04 PM
its possible , because hacker has already implemented this , so i think its possible for us also
Dec 9, 2021, 4:05 PM
I will pay to fix this contract,
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
interface AggregatorV3Interface {
function decimals() external view returns (uint8);
function description() external view returns (string memory);
function version() external view returns (uint256);
// getRoundData and latestRoundData should both raise "No data present"
// if they do not have data to report, instead of returning unset values
// which could be misinterpreted as actual reported values.
function getRoundData(uint80 _roundId)
external
view
returns (
uint80 roundId,
int256 answer,
uint256 startedAt,
uint256 updatedAt,
uint80 answeredInRound
);
function latestRoundData()
external
view
returns (
uint80 roundId,
int256 answer,
uint256 startedAt,
uint256 updatedAt,
uint80 answeredInRound
);
}
/**
* THIS EXAMPLE USES UN-AUDITED CODE.
* Network: Kovan
* Base: BTC/USD
* Base Address: 0x6135b13325bfC4B00278B4abC5e20bbce2D6580e
* Quote: EUR/USD
* Quote Address: 0x0c15Ab9A0DB086e062194c273CC79f41597Bbf13
* Decimals: 8
*/
contract PriceConverter {
AggregatorV3Interface public priceSource;
ERC20 public quote;
uint8 private decimals;
uint256 public fallbackPrice;
event FallbackPrice(
uint80 roundId,
int256 answer,
uint256 startedAt,
uint256 updatedAt,
uint80 answeredInRound
);
constructor(address _priceSource, address _quote, uint8 _decimals) public {
priceSource = AggregatorV3Interface(_priceSource);
quote = ERC20(_quote);
decimals = decimals;
}
function latestRoundData() public view
returns
(uint80 roundId,
int256 answer,
uint256 startedAt,
uint256 updatedAt,
uint80 answeredInRound
){
require(_decimals > uint8(0) && _decimals <= uint8(18), "Invalid _decimals");
( , int256 basePrice, , , ) = AggregatorV3Interface(_priceSource).latestRoundData();
uint8 baseDecimals = AggregatorV3Interface(priceSource).decimals();
basePrice = scalePrice(basePrice, baseDecimals, _decimals);
( , int256 quotePrice, , , ) = AggregatorV3Interface(_quote).latestRoundData();
uint8 quoteDecimals = AggregatorV3Interface(_quote).decimals();
quotePrice = scalePrice(quotePrice, quoteDecimals, _decimals);
return(roundId, answer, startedAt, updatedAt, answeredInRound);
}
function updateFallbackPrice() public {
(
uint80 roundId,
int256 answer,
uint256 startedAt,
uint256 updatedAt,
uint80 answeredInRound
) = priceSource.latestRoundData();
if (answer > 0) {
fallbackPrice = uint256(answer);
emit FallbackPrice(roundId,answer,startedAt,updatedAt,answeredInRound);
}
}
function scalePrice(int256 _price, uint8 _priceDecimals, uint8 _decimals)
internal
pure
returns (int256)
{
if (_priceDecimals < _decimals) {
return _price * int256(10 ** uint256(_decimals - _priceDecimals));
} else if (_priceDecimals > _decimals) {
return _price / int256(10 ** uint256(_priceDecimals - _decimals));
}
return _price;
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
interface AggregatorV3Interface {
function decimals() external view returns (uint8);
function description() external view returns (string memory);
function version() external view returns (uint256);
// getRoundData and latestRoundData should both raise "No data present"
// if they do not have data to report, instead of returning unset values
// which could be misinterpreted as actual reported values.
function getRoundData(uint80 _roundId)
external
view
returns (
uint80 roundId,
int256 answer,
uint256 startedAt,
uint256 updatedAt,
uint80 answeredInRound
);
function latestRoundData()
external
view
returns (
uint80 roundId,
int256 answer,
uint256 startedAt,
uint256 updatedAt,
uint80 answeredInRound
);
}
/**
* THIS EXAMPLE USES UN-AUDITED CODE.
* Network: Kovan
* Base: BTC/USD
* Base Address: 0x6135b13325bfC4B00278B4abC5e20bbce2D6580e
* Quote: EUR/USD
* Quote Address: 0x0c15Ab9A0DB086e062194c273CC79f41597Bbf13
* Decimals: 8
*/
contract PriceConverter {
AggregatorV3Interface public priceSource;
ERC20 public quote;
uint8 private decimals;
uint256 public fallbackPrice;
event FallbackPrice(
uint80 roundId,
int256 answer,
uint256 startedAt,
uint256 updatedAt,
uint80 answeredInRound
);
constructor(address _priceSource, address _quote, uint8 _decimals) public {
priceSource = AggregatorV3Interface(_priceSource);
quote = ERC20(_quote);
decimals = decimals;
}
function latestRoundData() public view
returns
(uint80 roundId,
int256 answer,
uint256 startedAt,
uint256 updatedAt,
uint80 answeredInRound
){
require(_decimals > uint8(0) && _decimals <= uint8(18), "Invalid _decimals");
( , int256 basePrice, , , ) = AggregatorV3Interface(_priceSource).latestRoundData();
uint8 baseDecimals = AggregatorV3Interface(priceSource).decimals();
basePrice = scalePrice(basePrice, baseDecimals, _decimals);
( , int256 quotePrice, , , ) = AggregatorV3Interface(_quote).latestRoundData();
uint8 quoteDecimals = AggregatorV3Interface(_quote).decimals();
quotePrice = scalePrice(quotePrice, quoteDecimals, _decimals);
return(roundId, answer, startedAt, updatedAt, answeredInRound);
}
function updateFallbackPrice() public {
(
uint80 roundId,
int256 answer,
uint256 startedAt,
uint256 updatedAt,
uint80 answeredInRound
) = priceSource.latestRoundData();
if (answer > 0) {
fallbackPrice = uint256(answer);
emit FallbackPrice(roundId,answer,startedAt,updatedAt,answeredInRound);
}
}
function scalePrice(int256 _price, uint8 _priceDecimals, uint8 _decimals)
internal
pure
returns (int256)
{
if (_priceDecimals < _decimals) {
return _price * int256(10 ** uint256(_decimals - _priceDecimals));
} else if (_priceDecimals > _decimals) {
return _price / int256(10 ** uint256(_priceDecimals - _decimals));
}
return _price;
}
}
Dec 9, 2021, 4:33 PM