MCPcopy Create free account
hub / github.com/QuipNetwork/cpp-sdk / abiEncode

Method abiEncode

src/quip_factory.cpp:394–425  ·  view source on GitHub ↗

Helper to call the abiEncode.ts script

Source from the content-addressed store, hash-verified

392
393 // Helper to call the abiEncode.ts script
394 std::string abiEncode(const std::string &functionName, const std::string &abi,
395 const std::string &paramsJson) {
396 // Note: The order of arguments must match abiEncode.ts
397 // 1. abi
398 // 2. function name
399 // 3. params
400 std::string command =
401 "cd ./ethereum-sdk && npx ts-node scripts/abiEncode.ts '" + abi +
402 "' '" + functionName + "' '" + paramsJson + "'";
403
404 FILE *pipe = popen(command.c_str(), "r");
405 if (!pipe) {
406 throw std::runtime_error("Failed to execute abiEncode script");
407 }
408
409 std::string result;
410 char buffer[128];
411 while (fgets(buffer, sizeof(buffer), pipe) != nullptr) {
412 result += buffer;
413 }
414
415 int status = pclose(pipe);
416 if (status != 0) {
417 throw std::runtime_error("abiEncode script failed: " + result);
418 }
419
420 // Remove newline from the end
421 if (!result.empty() && result[result.length() - 1] == '\n') {
422 result.erase(result.length() - 1);
423 }
424 return result;
425 }
426
427 std::string rpc_url_;
428 std::string contract_address_;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected