Class Felt
-
- All Implemented Interfaces:
-
com.swmansion.starknet.data.types.StarknetResponse
,com.swmansion.starknet.data.types.conversions.ConvertibleToCalldata
,kotlin.Comparable
@Serializable(with = FeltSerializer.class) public final class Felt extends NumAsHexBase implements ConvertibleToCalldata, StarknetResponse
-
-
Field Summary
Fields Modifier and Type Field Description public final static BigInteger
PRIME
public final static BigInteger
MAX
public final static Felt
ZERO
public final static Felt
ONE
private final BigInteger
value
-
Method Summary
Modifier and Type Method Description BigInteger
getValue()
List<Felt>
toCalldata()
String
toString()
String
hexString()
Encode as hexadecimal string, including "0x" prefix. String
decString()
Encode as decimal string. final String
hexStringPadded()
Encode as padded hexadecimal string, including "0x" prefix. final String
toShortString()
Encode as ASCII string, with up to 31 characters. final static Felt
fromHex(String value)
Create Felt from hex string. final static Felt
fromShortString(String value)
Create Felt from ASCII string. final static Felt
fromSigned(BigInteger value)
Create Felt from signed BigInteger value. final static Felt
fromSigned(Long value)
Create Felt from signed Long value. final static Felt
fromSigned(Integer value)
Create Felt from signed Int value. -
-
Constructor Detail
-
Felt
Felt(Long value)
-
Felt
Felt(Integer value)
-
Felt
Felt(BigInteger value)
-
-
Method Detail
-
getValue
BigInteger getValue()
-
toCalldata
List<Felt> toCalldata()
-
hexStringPadded
final String hexStringPadded()
Encode as padded hexadecimal string, including "0x" prefix. Its length is always 66 (including the 0x prefix).
-
toShortString
final String toShortString()
Encode as ASCII string, with up to 31 characters. Example: 0x68656c6c6f -> "hello".
-
fromHex
final static Felt fromHex(String value)
Create Felt from hex string. It must start with "0x" prefix.
- Parameters:
value
- hex string.
-
fromShortString
final static Felt fromShortString(String value)
Create Felt from ASCII string. It must be shorter than 32 characters and only contain ASCII encoding. Example: "hello" -> 0x68656c6c6f.
- Parameters:
value
- string transformed to felt.
-
fromSigned
final static Felt fromSigned(BigInteger value)
Create Felt from signed BigInteger value. It must be in range (-Felt.PRIME, Felt.PRIME).
Calculated as value mod Felt.PRIME.
-
fromSigned
final static Felt fromSigned(Long value)
Create Felt from signed Long value.
Calculated as value mod Felt.PRIME.
-
fromSigned
final static Felt fromSigned(Integer value)
Create Felt from signed Int value.
Calculated as value mod Felt.PRIME.
-
-
-
-