Global Functions

The Global functions can be used in anywhere of the SCORE project.
Some functions can charge more STEPs due to the usage of CPU.

create_address_with_key(public_key: bytes) → Optional[iconservice.base.address.Address]

Create an address with a given public key

Parameters:public_key – Public key based on secp256k1
Returns:Address created from a given public key or None if failed
json_dumps(obj: Any) → str

Converts a python object obj to a JSON string

Parameters:obj – a python object to be converted
Returns:json string
json_loads(src: str) → Any

Parses a JSON string src and converts it to a python object

Parameters:src – a JSON string to be converted
Returns:a python object
recover_key(msg_hash: bytes, signature: bytes, compressed: bool = True) → Optional[bytes]

Returns the public key from message hash and recoverable signature

Parameters:
  • msg_hash – 32 bytes data
  • signature – signature_data(64) + recovery_id(1)
  • compressed – the type of public key to return
Returns:

public key recovered from msg_hash and signature (compressed: 33 bytes key, uncompressed: 65 bytes key)

revert(message: Optional[str] = None, code: int = 0) → None

Reverts the transaction and breaks. All the changes of state DB in current transaction will be rolled back.

Parameters:
  • message – revert message
  • code – code
sha3_256(data: bytes) → bytes

Computes hash using the input data

Parameters:data – input data
Returns:hashed data in bytes