In my project - I try to iterate with smartcontracts(bep20/erc20). I've implemented some dummy bep20/erc20 smartcontracts and prepared docker images to run with premined deposited addresses my integrational tests. In eth chain I'have no problems - I can get balance and send my tokens between addresses. But in bsc chain - I have a problem - no reaction. I can't nither work with balances or transfers nor with contract info(totalSupply/decimals/symbol/name functions don't respond anything.)
bsc(geth) source: https://github.com/binance-chain/bsc (master)
entrypoint docker-image script body
/usr/local/bin/geth --config ${DATA_DIR}/config.toml --datadir ${DATA_DIR} \
--password /passphrase \
init /genesis.json
echo "IMPORTING DEPOSIT_ADDRESS: $DEPOSIT_ADDRESS <= $DEPOSIT_ADDRESS_PRIVATE_KEY"
/usr/local/bin/geth --config ${DATA_DIR}/config.toml --datadir ${DATA_DIR} \
--password /passphrase \
account import <(echo $DEPOSIT_ADDRESS_PRIVATE_KEY)
/usr/local/bin/geth --config ${DATA_DIR}/config.toml --datadir ${DATA_DIR} \
--verbosity 5 --log.debug --nousb \
--password /passphrase \
--fakepow --nodiscover --maxpeers 0 \
--http.api personal,db,eth,net,web3 \
--networkid 1999 --mine --miner.threads=2 --miner.etherbase $DEPOSIT_ADDRESS --vmdebug
ibep20.sol file:
// SPDX-License-Identifier: MIT
// pragma solidity ^0.5.1;
pragma solidity ^0.8.13;
// https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.0.0/contracts/token/ERC20/IERC20.sol
interface IBEP20 {
function totalSupply() external view returns (uint);
function balanceOf(address account) external view returns (uint);
function transfer(address recipient, uint amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint);
function approve(address spender, uint amount) external returns (bool);
function transferFrom(
address sender,
address recipient,
uint amount
) external returns (bool);
event Transfer(address indexed from, address indexed to, uint value);
event Approval(address indexed owner, address indexed spender, uint value);
}
bep20.sol
// SPDX-License-Identifier: MIT
// pragma solidity ^0.5.0;
pragma solidity ^0.8.13;
import "./ibep20.sol";
contract BEP20 is IBEP20 {
uint public totalSupply;
mapping(address => uint) public balanceOf;
mapping(address => mapping(address => uint)) public allowance;
string public name = "usdt";
string public symbol = "usdt";
uint8 public decimals = 6;
function transfer(address recipient, uint256 amount) external returns (bool) {
balanceOf[msg.sender] -= amount;
balanceOf[recipient] += amount;
emit Transfer(msg.sender, recipient, amount);
return true;
}
function approve(address spender, uint amount) external returns (bool) {
allowance[msg.sender][spender] = amount;
emit Approval(msg.sender, spender, amount);
return true;
}
function transferFrom(
address sender,
address recipient,
uint amount
) external returns (bool) {
allowance[sender][msg.sender] -= amount;
balanceOf[sender] -= amount;
balanceOf[recipient] += amount;
emit Transfer(sender, recipient, amount);
return true;
}
function mint(uint amount) external {
balanceOf[msg.sender] += amount;
totalSupply += amount;
emit Transfer(address(0), msg.sender, amount);
}
function burn(uint amount) external {
balanceOf[msg.sender] -= amount;
totalSupply -= amount;
emit Transfer(msg.sender, address(0), amount);
}
// constructor() {
constructor() public {
uint256 correctBalance = 1000 * 10 ** decimals;
// uint correctBalance = 1000 * 10 ** decimals;
balanceOf[msg.sender] = correctBalance;
totalSupply = correctBalance;
emit Transfer(address(0), msg.sender, correctBalance);
}
}
I've tried to compile it with solc(v0.5.*) and with (0.8.13) - It didn't help.
In geth logs I see that smartcontract was deployed successfully
INFO [09-19|15:13:29.500|internal/ethapi/api.go:2080] Submitted contract creation hash=0x3f42c1dba1f53977db93677663b6d56ac8cb51681295ff93d7f047f308045ccc from=0xd3aE0500e21008c89CA4746be7522340C67F5730 nonce=0 contract=0x4B1Ed695C76af5Dbd305AFA41FBC3E7002e735D4 value=0
and Also eth_getTransactionByHash shows that it was mined(0x3f42c1dba1f53977db93677663b6d56ac8cb51681295ff93d7f047f308045ccc)
and when I try to call smart contract:
➜ bsc git:(dev) ✗ curl -X POST http://127.0.0.1:10000 -H "Content-Type: application/json" --data \
> '{"jsonrpc":"2.0","method":"eth_call","params":[{"to": "0x4b1ed695c76af5dbd305afa41fbc3e7002e735d4", "data": "0x70a08231000000000000000000000000d3ae0500e21008c89ca4746be7522340c67f5730"}, "latest"],"id":1}'
{"jsonrpc":"2.0","id":1,"result":"0x"}
and in geth logs:
DEBUG[09-19|15:21:24.534|internal/ethapi/api.go:906] Executing EVM call finished runtime="158.331µs"
DEBUG[09-19|15:21:24.534|rpc/handler.go:313] Served eth_call conn=127.0.0.1:43962 reqid=1 duration="308.631µs"