Skip to content
This repository has been archived by the owner on Oct 28, 2021. It is now read-only.

How to RLP encode a JSON String for a raw transaction? #5884

Open
Bowfish opened this issue Feb 2, 2020 · 1 comment
Open

How to RLP encode a JSON String for a raw transaction? #5884

Bowfish opened this issue Feb 2, 2020 · 1 comment

Comments

@Bowfish
Copy link

Bowfish commented Feb 2, 2020

I'm new to RLP encoding. I'm writing a C++ application in Qt which should send a raw transaction. I installed and compiled the aleth framework. What are the steps to get an RLP encoded string of a JSON?

My JSON looks like this:

{
  nonce: '0x6',
  gasPrice: '0x09184e72a000', 
  gasLimit: '0x30000',
  to: '0xfa3caabc8eefec2b5e2895e5afbf79379e7268a7', 
  value: '0x00'
};

I've tried the following:

dev::RLP *m_rlp;

m_rlp = new dev::RLP(json, dev::RLP::VeryStrict);

If I compile and run the application I get the following error:

terminate called after throwing an instance of 'boost::wrapexcept<dev::OversizeRLP>'
  what():  /home/damian/src/aleth/libdevcore/RLP.cpp(28): Throw in function dev::RLP::RLP(dev::bytesConstRef, dev::RLP::Strictness)
Dynamic exception type: boost::wrapexcept<dev::OversizeRLP>
[dev::tag_comment*] = Actual size: 1, data size: 10
@gumb0
Copy link
Member

gumb0 commented Feb 17, 2020

You'll have to parse your JSON first with some library, then use RLPStream class to encode the data.

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

No branches or pull requests

2 participants