Skip to content

StrToBig

Converts a string representation of a number to a big.Int.

Function Signature

func StrToBig(str string) *big.Int

Source: keccak.go

Parameters

  • str - The string to convert to a *big.Int (numeric string representation)

Returns

  • *big.Int - A pointer to a big.Int representing the converted value

Usage Example

package main
 
import (
	"fmt"
	"github.com/NethermindEth/starknet.go/utils"
)
 
func main() {
	// Convert numeric string to big.Int
	numStr := "123456789012345678901234567890"
	bigInt := utils.StrToBig(numStr)
 
	fmt.Printf("String: %s\n", numStr)
	fmt.Printf("Big Int: %s\n", bigInt.String())
	fmt.Printf("Type: %T\n", bigInt)
	// Output:
	// String: 123456789012345678901234567890
	// Big Int: 123456789012345678901234567890
	// Type: *big.Int
}

Common Use Cases

  1. Converting numeric config values to big.Int.
  2. Parsing large numbers from JSON responses.
  3. Handling fee amounts that exceed standard integer limits.
  4. Processing large token quantities with high decimal precision.

See Also