Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InvalidProtocolBufferException ABI #122

Open
d1ksim opened this issue Apr 9, 2024 · 3 comments
Open

InvalidProtocolBufferException ABI #122

d1ksim opened this issue Apr 9, 2024 · 3 comments

Comments

@d1ksim
Copy link

d1ksim commented Apr 9, 2024

Hello, friends.

When using trident java and publishing a smart contract, I get the error: com.google.protobuf.InvalidProtocolBufferException: Expect message object but got

I don't understand what the problem is, I follow the instructions strictly.

https://gist.github.com/d1ksim/1a915d9c13a1efefe92e2059c3d06465

@endiaoekoe
Copy link
Contributor

com.google.protobuf.InvalidProtocolBufferException: Expect message object but got

hi, @d1ksim
From the error msg and codes you provide above, it seems like there is a mismatch between the expected protocol buffer message format and the actual data being passed.
Most likely, there is something wrong when generating the able string.
When setting the ABI for the contract, make sure you are passing it as a ByteString(you use String in your code) or in a format that the trident-java library expects.
maybe you can try and see if it works fine.

@pendejo-dev
Copy link

com.google.protobuf.InvalidProtocolBufferИсключение: ожидайте объекта сообщения, но получили

привет, @d1ksimСудя по ошибке msg и кодам, которые вы предоставили выше, кажется, что существует несоответствие между ожидаемым форматом буферного сообщения протокола и фактическими передаваемыми данными.Скорее всего, что-то не так при генерации умелой строки.Устанавливая ABI для контракта, убедитесь, что вы передаете его как ByteString (вы используете String в своем коде) или в формате, который ожидает библиотека trident-java.возможно, вы попробуете посмотреть, работает ли это нормально.

How can I pass the ABI as a ByteString if setAbi accepts a String?

@endiaoekoe
Copy link
Contributor

How can I pass the ABI as a ByteString if setAbi accepts a String?

You need to convert your ABI JSON string to a ByteString before passing it to the setAbi method. Here's how you can do it using the com.google.protobuf.ByteString class:

import com.google.protobuf.ByteString;
// ... other imports

String abiJson = /* Your ABI JSON string */;
ByteString abiByteString = ByteString.copyFromUtf8(abiJson); // Convert to ByteString

// ... create your contract object ...

contract.setAbi(abiByteString); // Set the ByteString ABI

// ... continue with contract deployment ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants