Module: Solana::Utils

Defined in:
lib/solana-ruby/utils.rb

Overview

The Utils module provides utility methods and constants for interacting with the Solana blockchain.

Defined Under Namespace

Modules: DEVNET, InstructionType, MAINNET, TESTNET

Constant Summary collapse

SYSTEM_PROGRAM_ID =

The system program ID for Solana.

'11111111111111111111111111111111'
PACKET_DATA_SIZE =

The maximum packet data size for Solana transactions.

1232

Class Method Summary collapse

Class Method Details

.base58_decode(base58) ⇒ String

Decodes a Base58 string into a byte array.

Parameters:

  • base58 (String)

    The Base58 string to decode.

Returns:

  • (String)

    The decoded byte array.



84
85
86
# File 'lib/solana-ruby/utils.rb', line 84

def self.base58_decode(base58)
  Base58.base58_to_binary(base58, :bitcoin)
end

.base58_encode(bytes) ⇒ String

Encodes a byte array into a Base58 string.

Parameters:

  • bytes (String)

    The byte array to encode.

Returns:

  • (String)

    The Base58-encoded string.



75
76
77
# File 'lib/solana-ruby/utils.rb', line 75

def self.base58_encode(bytes)
  Base58.binary_to_base58(bytes, :bitcoin)
end

.base64_decode(base64) ⇒ String

Decodes a Base64 string into a byte array.

Parameters:

  • base64 (String)

    The Base64 string to decode.

Returns:

  • (String)

    The decoded byte array.



102
103
104
# File 'lib/solana-ruby/utils.rb', line 102

def self.base64_decode(base64)
  Base64.strict_decode64(base64)
end

.base64_encode(bytes) ⇒ String

Encodes a byte array into a Base64 string.

Parameters:

  • bytes (String)

    The byte array to encode.

Returns:

  • (String)

    The Base64-encoded string.



93
94
95
# File 'lib/solana-ruby/utils.rb', line 93

def self.base64_encode(bytes)
  Base64.strict_encode64(bytes)
end