bytes to hash with a specific encoding and a hash_function, and gets a similar response.
For examples of how to use raw sign for a specific chain, see this recipe.
- REST API
- NodeJS
- Java
- React
- React Native
Sign a raw hash or A successful response will look like:Alternatively, you can provide bytes to hash with a specific encoding and hash function, and gets a similar response.
bytes (with encoding and hash_function) along the blockchain’s cryptographic curve using the wallet’s private key. Make a POST request toReport incorrect code
Copy
Ask AI
https://api.privy.io/v1/wallets/{wallet_id}/raw_sign
Usage
Report incorrect code
Copy
Ask AI
curl --request POST \
--url https://api.privy.io/v1/wallets/{wallet_id}/raw_sign \
--header 'Authorization: Basic Y20xNWh4eDUyMDVlNWx2NHVkdmE3enBqejoybWhVOWhhVTFQYjhYNXV1cVdxQVRIdW5xTWIyUlBKRm5GSHRzWDVzbXNkdUJRUDZtTW05YldmalBwS3hocjJQZHNHY0Q5NkFUeDc5em03WWhicUZLWkM4' \
--header 'Content-Type: application/json' \
--header 'privy-app-id: <privy-app-id>' \
--data '{
"params": {
"hash": "0x0775aeed9c9ce6e0fbc4db25c5e4e6368029651c905c286f813126a09025a21e"
}
}'
Report incorrect code
Copy
Ask AI
{
"data": {
"signature": "0x0775aeed9c9ce6e0fbc4db25c5e4e6368029651c905c286f813126a09025a21e",
"encoding": "hex"
}
}
Report incorrect code
Copy
Ask AI
curl --request POST \
--url https://api.privy.io/v1/wallets/{wallet_id}/raw_sign \
--header 'Authorization: Basic Y20xNWh4eDUyMDVlNWx2NHVkdmE3enBqejoybWhVOWhhVTFQYjhYNXV1cVdxQVRIdW5xTWIyUlBKRm5GSHRzWDVzbXNkdUJRUDZtTW05YldmalBwS3hocjJQZHNHY0Q5NkFUeDc5em03WWhicUZLWkM4' \
--header 'Content-Type: application/json' \
--header 'privy-app-id: <privy-app-id>' \
--data '{
"params": {
"bytes": "0a0234ea220809701d7a17a77e04408093e981a6335a66080112620a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412310a15417009bf59e27d2031a23a61e1590289fc3d21b3cd121541132b98ed6fb80a2d45f177cdef091ae2d9dc115418e80770a0bee581a633",
"encoding": "hex",
"hash_function": "sha256"
}
}'
Authorization
App secret authentication.
Headers
ID of your Privy app.
Request authorization signature. If multiple signatures are required, they should be comma
separated.
Path
ID of the wallet.
Body
Hide child attributes
Hide child attributes
Option 1: Sign a pre-computed hashOption 2: Hash bytes before signing
The hex-encoded hash to sign, prefixed with
0x. Use this option when you have already computed the hash.The bytes to hash and sign. Use this option to provide raw data that will be decoded using the specified
encoding then hashed using the specified hash_function.The encoding scheme for the bytes. Required when using
bytes. Available options: utf-8, hexThe hash function to hash the bytes. Required when using
bytes. Available options: keccak256, sha256You must provide either
hash OR the combination of bytes, encoding, and hash_function. These parameter sets are mutually exclusive.Response
Use the Alternatively, you can provide bytes to hash with a specific encoding and hash function, and gets a similar response.
rawSign method on the wallets() interface to sign a hash or bytes (with encoding and hash_function) with a wallet.Usage
Report incorrect code
Copy
Ask AI
const {signature, encoding} = await privy.wallets().rawSign('insert-wallet-id', {
params: { hash: '0x0775aeed9c9ce6e0fbc4db25c5e4e6368029651c905c286f813126a09025a21e' },
});
Report incorrect code
Copy
Ask AI
const {signature, encoding} = await privy.wallets().rawSign('insert-wallet-id', {
params: {
bytes: "0a0234ea220809701d7a17a77e04408093e981a6335a66080112620a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412310a15417009bf59e27d2031a23a61e1590289fc3d21b3cd121541132b98ed6fb80a2d45f177cdef091ae2d9dc115418e80770a0bee581a633",
encoding: "hex",
hash_function: "sha256"
},
});
Parameters and Returns
Check out the API reference for more details.To sign a raw hash or
bytes (with encoding and hash_function) from your wallet, use the rawSign method.
It will sign your hash, and return the signature to you.Usage
Report incorrect code
Copy
Ask AI
try {
RawSignRequest request = RawSignRequest.builder()
.params(
RawSignRequestParams.builder()
.hash("0x0775aeed9c9ce6e0fbc4db25c5e4e6368029651c905c286f813126a09025a21e")
.build()
)
.build();
// Alternatively, you can provide bytes to hash with a specific encoding and hash function, and gets a similar response.
/*
RawSignRequest request = RawSignRequest.builder()
.params(
RawSignRequestParams.builder()
.bytes("0a0234ea220809701d7a17a77e04408093e981a6335a66080112620a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412310a15417009bf59e27d2031a23a61e1590289fc3d21b3cd121541132b98ed6fb80a2d45f177cdef091ae2d9dc115418e80770a0bee581a633")
.encoding("hex")
.hashFunction("sha256")
.build()
)
.build();
*/
// Example: If wallet's owner is an authorization private key
AuthorizationContext authorizationContext = AuthorizationContext.builder()
.addAuthorizationPrivateKey("authorization-key")
.build();
WalletRawSignResponse response = privyClient
.wallets()
.rawSign(
walletId,
request,
authorizationContext
);
if (response.rawSignResponse().isPresent()) {
RawSignResponse rawSignResponse = response.rawSignResponse().get();
if (rawSignResponse.data().isPresent()) {
RawSignResponseData data = rawSignResponse.data().get();
String signature = data.signature();
}
}
} catch (APIException e) {
String errorBody = e.bodyAsString();
System.err.println(errorBody);
} catch (Exception e) {
System.err.println(e.getMessage());
}
Parameters
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Option 1: Sign a pre-computed hashOption 2: Hash bytes before signing
The hex-encoded hash to sign, prefixed with
0x. Use this option when you have already computed the hash.The bytes to hash and sign. Use this option to provide raw data that will be decoded using the specified
encoding then hashed using the specified hash_function.The encoding scheme for the bytes. Required when using
bytes. Available options: utf-8, hexThe hash function to hash the bytes. Required when using
bytes. Available options: keccak256, sha256You must provide either
hash OR the combination of bytes, encoding, and hash_function. These parameter sets are mutually exclusive.Returns
TheWalletRawSignResponse object contains a rawSignResponse() fieldSign a raw hash or Option 1: Sign a pre-computed hashOption 2: Hash bytes before signing
bytes (with encoding and hash_function) along the blockchain’s cryptographic curve using the wallet’s private key.Report incorrect code
Copy
Ask AI
signRawHash: ({address: string, chainType: CurveSigningChainType, hash: HexString}) =>
Promise<{signature: HexString}>;
Usage
Report incorrect code
Copy
Ask AI
import {useSignRawHash} from '@privy-io/react-auth/extended-chains';
const {signRawHash} = useSignRawHash();
const {signature} = await signRawHash({
address: 'insert-wallet-address',
chainType: 'cosmos', // or 'stellar', 'sui', etc.
hash: '0x1acab030f479bda7829de07e9db4138cec5d38574df17d65af1617b7268541c0'
});
// Alternatively, you can provide bytes to hash with a specific encoding and hash function, and gets a similar response.
/*
const {signature} = await signRawHash({
address: 'insert-wallet-address',
chainType: 'cosmos', // or 'stellar', 'sui', etc.
bytes: '0a0234ea220809701d7a17a77e04408093e981a6335a66080112620a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412310a15417009bf59e27d2031a23a61e1590289fc3d21b3cd121541132b98ed6fb80a2d45f177cdef091ae2d9dc115418e80770a0bee581a633',
encoding: 'hex',
hash_function: 'sha256'
});
*/
console.log(signature);
// 0x4d349c0c04abec47f2af0929b6dd5abcef2f29cb90b596772af928b3ef6e34316108eab1c47fac6d1d5ec51da59bd9124a80c4d353e130a8e675a3ad952e4c46
Parameters
The address of the wallet to use for signing the raw hash.
The chain type of the wallet to use for signing the raw hash.
The raw hash to sign over, hex-encoded and prefixed with
0x. Use this option when you have already computed the hash.The bytes to hash and sign. Use this option to provide raw data that will be decoded using the specified
encoding then hashed using the specified hash_function.The encoding scheme for the bytes. Required when using
bytes.The hash function to hash the bytes. Required when using
bytes.You must provide either
hash OR the combination of bytes, encoding, and hash_function. These parameter sets are mutually exclusive.Returns
Hide child properties
Hide child properties
The signature produced by the wallet. Hex-encoded and prefixed with
0x.Sign a raw hash or Option 1: Sign a pre-computed hashOption 2: Hash bytes before signing
bytes (with encoding and hash_function) along the blockchain’s cryptographic curve using the wallet’s private key.Report incorrect code
Copy
Ask AI
signRawHash: ({address: string, chainType: CurveSigningChainType, hash: HexString}) =>
Promise<{signature: HexString}>;
Usage
Report incorrect code
Copy
Ask AI
import {useSignRawHash} from '@privy-io/expo/extended-chains';
const {signRawHash} = useSignRawHash();
const {signature} = await signRawHash({
address: 'insert-wallet-address',
chainType: 'cosmos', // or 'stellar', 'sui', etc.
hash: '0x1acab030f479bda7829de07e9db4138cec5d38574df17d65af1617b7268541c0'
});
// Alternatively, you can provide bytes to hash with a specific encoding and hash function, and gets a similar response.
/*
const {signature} = await signRawHash({
address: 'insert-wallet-address',
chainType: 'cosmos', // or 'stellar', 'sui', etc.
bytes: '0a0234ea220809701d7a17a77e04408093e981a6335a66080112620a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412310a15417009bf59e27d2031a23a61e1590289fc3d21b3cd121541132b98ed6fb80a2d45f177cdef091ae2d9dc115418e80770a0bee581a633',
encoding: 'hex',
hash_function: 'sha256'
});
*/
console.log(signature);
// 0x4d349c0c04abec47f2af0929b6dd5abcef2f29cb90b596772af928b3ef6e34316108eab1c47fac6d1d5ec51da59bd9124a80c4d353e130a8e675a3ad952e4c46
Parameters
The address of the wallet to use for signing the raw hash.
The chain type of the wallet to use for signing the raw hash.
The raw hash to sign over, hex-encoded and prefixed with
0x. Use this option when you have already computed the hash.The bytes to hash and sign. Use this option to provide raw data that will be decoded using the specified
encoding then hashed using the specified hash_function.The encoding scheme for the bytes. Required when using
bytes.The hash function to hash the bytes. Required when using
bytes.You must provide either
hash OR the combination of bytes, encoding, and hash_function. These parameter sets are mutually exclusive.Returns
Hide child properties
Hide child properties
The signature produced by the wallet. Hex-encoded and prefixed with
0x.
