EOSIO / eos

An open source smart contract platform
https://developers.eos.io/manuals/eos
MIT License
11.28k stars 3.76k forks source link

How to create & sign a transaction from c++ code #10873

Closed nidhaloff closed 3 years ago

nidhaloff commented 3 years ago

Hey y'all,

I hope you are doing well.

I'm trying to figure out how to create and sign a transaction from c++ code. I know how to do this with cleos or eosjs. However, how can I do this in plain c++?

I searched a lot before opening the issue, but it looks like there are no examples out there.

heifner commented 3 years ago

An example from the transaction generator plugin: https://github.com/EOSIO/eos/blob/master/plugins/txn_test_gen_plugin/txn_test_gen_plugin.cpp#L158

Many examples in the unittests, for example: https://github.com/EOSIO/eos/blob/master/unittests/misc_tests.cpp#L1079

praphael commented 3 years ago

Assuming you are using an a RPC endpoint, you need to supply proper JSON for the HTTP request. Use cleos --print-request to determine that. There are many stages, mutliple requests, including fetching data from the chain, etc. MIght also help to look at the cleos source code, as well.