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 BigIntegerPRIMEpublic final static BigIntegerMAXpublic final static FeltZEROpublic final static FeltONEprivate final BigIntegervalue
-
Method Summary
Modifier and Type Method Description BigIntegergetValue()List<Felt>toCalldata()StringtoString()StringhexString()Encode as hexadecimal string, including "0x" prefix. StringdecString()Encode as decimal string. final StringhexStringPadded()Encode as padded hexadecimal string, including "0x" prefix. final StringtoShortString()Encode as ASCII string, with up to 31 characters. final static FeltfromHex(String value)Create Felt from hex string. final static FeltfromShortString(String value)Create Felt from ASCII string. final static FeltfromSigned(BigInteger value)Create Felt from signed BigInteger value. final static FeltfromSigned(Long value)Create Felt from signed Long value. final static FeltfromSigned(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.
-
-
-
-