AlphaWallet / AlphaWallet/Web3E

Runtime error on ESP32 using Contract.h

Đang mở
#9 2 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
C
Star
152
Fork
45
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

I’m using Web3E with an ESP32. Standalone `Web3.h` works fine, but `Contract.h` causes problems, though.
This is what I’m trying to do:

```
queryERC20Balance(ERC20CONTRACT, MY_ADDRESS);
```

Whereas `void queryERC20Balance(const char* Address, const char* ERC20ContractAddress)` is taken from the [repo examples](https://github.com/AlphaWallet/Web3E/blob/master/examples/Query%20Token%20Balance/main.cpp):

```
void queryERC20Balance(const char* contractAddress, const char *userAddress)
{
String address = userAddress;

string param = contract.SetupContractData("balanceOf(address)", &address);
string result = contract.ViewCall(¶m);

param = contract.SetupContractData("decimals()", &address);
result = contract.ViewCall(¶m);

int decimals = web3.getInt(&result);

uint256_t baseBalance = web3.getUint256(&result);
string balanceStr = Util::ConvertWeiToEthString(&baseBalance, decimals); //use decimals to calculate value, not all ERC20 use 18 decimals

Serial.println(balanceStr.c_str());
}
```

This is the decoded backtrace:

```
Backtrace: 0x40085058:0x3ffb1ba0 0x400852d5:0x3ffb1bc0 0x400f6777:0x3ffb1be0 0x400f67be:0x3ffb1c00 0x400f5ddf:0x3ffb1c20 0x400f61de:0x3ffb1c40 0x400fc00d:0x3ffb1c60 0x400d239f:0x3ffb1c80 0x400d254b:0x3ffb1cb0 0x400d2b65:0x3ffb1d40 0x400d1a47:0x3ffb1eb0 0x400d1c92:0x3ffb1f80 0x400df282:0x3ffb1fb0 0x400862d6:0x3ffb1fd0
#0 0x40085058:0x3ffb1ba0 in invoke_abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/panic.c:715
#1 0x400852d5:0x3ffb1bc0 in abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/panic.c:715
#2 0x400f6777:0x3ffb1be0 in __cxxabiv1::__terminate(void (*)()) at /builds/idf/crosstool-NG/.build/src/gcc-5.2.0/libstdc++-v3/libsupc++/eh_terminate.cc:112
#3 0x400f67be:0x3ffb1c00 in std::terminate() at /builds/idf/crosstool-NG/.build/src/gcc-5.2.0/libstdc++-v3/libsupc++/eh_terminate.cc:112
#4 0x400f5ddf:0x3ffb1c20 in __cxa_throw at /builds/idf/crosstool-NG/.build/src/gcc-5.2.0/libstdc++-v3/libsupc++/eh_throw.cc:87
#5 0x400f61de:0x3ffb1c40 in operator new(unsigned int) at /builds/idf/crosstool-NG/.build/src/gcc-5.2.0/libstdc++-v3/libsupc++/new_op.cc:54
#6 0x400fc00d:0x3ffb1c60 in __gnu_cxx::new_allocator::allocate(unsigned int, void const*) at /builds/idf/crosstool-NG/.build/xtensa-esp32-elf/build/build-cc-gcc-final/xtensa-esp32-elf/libstdc++-v3/include/bits/basic_string.h:2200
(inlined by) std::allocator_traits >::allocate(std::allocator&, unsigned int) at /builds/idf/crosstool-NG/.build/xtensa-esp32-elf/build/build-cc-gcc-final/xtensa-esp32-elf/libstdc++-v3/include/bits/alloc_traits.h:360
(inlined by) std::__cxx11::basic_string, std::allocator >::_M_create(unsigned int&, unsigned int) at /builds/idf/crosstool-NG/.build/xtensa-esp32-elf/build/build-cc-gcc-final/xtensa-esp32-elf/libstdc++-v3/include/bits/basic_string.tcc:157
#7 0x400d239f:0x3ffb1c80 in void std::__cxx11::basic_string, std::allocator >::_M_construct(char*, char*, std::forward_iterator_tag) at /Users/keno/.platformio/packages/toolchain-xtensa32/xtensa-esp32-elf/include/c++/5.2.0/bits/basic_string.tcc:223
#8 0x400d254b:0x3ffb1cb0 in void std::__cxx11::basic_string, std::allocator >::_M_construct_aux(char*, char*, std::__false_type) at /Users/keno/.platformio/packages/toolchain-xtensa32/xtensa-esp32-elf/include/c++/5.2.0/bits/basic_string.h:195
(inlined by) void std::__cxx11::basic_string, std::allocator >::_M_construct(char*, char*) at /Users/keno/.platformio/packages/toolchain-xtensa32/xtensa-esp32-elf/include/c++/5.2.0/bits/basic_string.h:214
(inlined by) std::__cxx11::basic_string, std::allocator >::basic_string(std::__cxx11::basic_string, std::allocator > const&) at /Users/keno/.platformio/packages/toolchain-xtensa32/xtensa-esp32-elf/include/c++/5.2.0/bits/basic_string.h:401
(inlined by) Contract::GenerateBytesForAddress(std::__cxx11::basic_string, std::allocator > const*) at lib/Web3E/src/Contract.cpp:216
#9 0x400d2b65:0x3ffb1d40 in Contract::SetupContractData[abi:cxx11](char const*, ...) at lib/Web3E/src/Contract.cpp:99 (discriminator 7)
#10 0x400d1a47:0x3ffb1eb0 in queryERC20Balance(char const*, char const*) at src/main.cpp:101
#11 0x400d1c92:0x3ffb1f80 in setup() at src/main.cpp:88
#12 0x400df282:0x3ffb1fb0 in loopTask(void*) at /Users/keno/.platformio/packages/framework-arduinoespressif32/cores/esp32/main.cpp:32
#13 0x400862d6:0x3ffb1fd0 in vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c:355 (discriminator 1)
```

Can someone help me with that, please? It seems there’s a probkem with `Contract::GenerateBytesForAddress()`, right?

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.