Skip to content

Add core/eosio library method to Convert String to public_key #357

@bhazzard

Description

@bhazzard

As a smart contract developer, I want a CDT core/eosio library method that converts a string (e.g., from a transfer memo) into a public_key object, so that I can parse and use public keys directly in contracts without relying on fragile workarounds or requiring a hard fork.


Context

Currently, there's no straightforward way to convert a public key string (like "EOS6MRy...") into a usable public_key object within a smart contract. Developers often resort to manual base58 decoding and checksum verification, which is error-prone and not ideal for contract logic.


Problem

Several smart contracts—such as openvaccount, openaccounts, makeaccounts, and signupeoseos—rely on parsing public keys from transfer memos to create new accounts. These contracts currently support only EOS-prefixed keys due to the absence of a reliable method to handle newer key formats (e.g., PUB_K1, PUB_R1). This limits both flexibility and future compatibility.


Acceptance Criteria

Introduce a CDT core/eosio library method (e.g., string_to_public_key) that parses a public key string into a public_key object.

Ensure the method supports all valid EOS key formats, including EOS, PUB_K1, and PUB_R1.

Provide documentation with usage examples and integration guidance.


Notes

By handling this at compile time via a CDT/eosio library method, we avoid the need for a hard fork while still enabling cleaner and safer contract development. This improves developer experience and allows support for a wider range of key formats in existing and future smart contracts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions