> ## Documentation Index
> Fetch the complete documentation index at: https://docs.privy.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Raw signing

> Integrate chains with Privy raw sign functionality over transaction hashes

For chains integrated through [raw signing](https://docs.privy.io/wallets/overview/chains.md), your app can invoke Privy's raw sign functionality to sign over a hash, e.g. the hash of a transaction. Your app can then use the returned signature to submit and send the transaction.

Alternatively, you can provide the `bytes` to hash with a specific `encoding` and a `hash_function`, and get the same response.

For examples of how to use raw sign for a specific chain, see the [Tier 1 integration
guide](https://docs.privy.io/recipes/tier-1-wallet-integration.md).

> [!NOTE]
>
> For Tron transactions, use the structured
> [`tron_signTransaction`](https://docs.privy.io/wallets/using-wallets/tron/sign-a-transaction) or
> [`tron_sendTransaction`](https://docs.privy.io/wallets/using-wallets/tron/send-a-transaction) methods. Use raw signing
> only when your client-side or low-level flow requires it.

**REST API**

Sign a raw hash or `bytes` (with `encoding` and `hash_function`) along the blockchain’s cryptographic curve using the wallet’s private key. Make a `POST` request to

```bash theme={"system"}
https://api.privy.io/v1/wallets/{wallet_id}/raw_sign
```

## Usage

```bash theme={"system"}
curl --request POST \
--url https://api.privy.io/v1/wallets/{wallet_id}/raw_sign \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--header 'privy-app-id: <privy-app-id>' \
--data '{
"params": {
    "hash": "0x0775aeed9c9ce6e0fbc4db25c5e4e6368029651c905c286f813126a09025a21e"
    }
}'
```

A successful response will look like:

```json theme={"system"}
{
    "data": {
        "signature": "0x0775aeed9c9ce6e0fbc4db25c5e4e6368029651c905c286f813126a09025a21e",
        "encoding": "hex"
    }
}
```

Alternatively, you can provide bytes to hash with a specific encoding and hash function, and gets a similar response.

```bash theme={"system"}
curl --request POST \
--url https://api.privy.io/v1/wallets/{wallet_id}/raw_sign \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--header 'privy-app-id: <privy-app-id>' \
--data '{
"params": {
    "bytes": "0a0234ea220809701d7a17a77e04408093e981a6335a66080112620a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412310a15417009bf59e27d2031a23a61e1590289fc3d21b3cd121541132b98ed6fb80a2d45f177cdef091ae2d9dc115418e80770a0bee581a633",
    "encoding": "hex",
    "hash_function": "sha256"
    }
}'
```

## Authorization

**Authorization** `string` *required*

App secret authentication.

## Headers

**privy-app-id** `string` *required*

ID of your Privy app.

**privy-authorization-signature** `string`

Request authorization signature. If multiple signatures are required, they should be comma
separated.

## Path

**wallet\_id** `string` *required*

ID of the wallet.

## Body

**params** `object` *required*

**child attributes**

**Option 1: Sign a pre-computed hash**

**hash** `string`

The hex-encoded hash to sign, prefixed with `0x`. Use this option when you have already computed the hash.

**Option 2: Hash bytes before signing**

**bytes** `string`

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`.

**encoding** `string`

The encoding scheme for the bytes. Required when using `bytes`. Available options: `utf-8`, `hex`

**hash\_function** `string`

The hash function to hash the bytes. Required when using `bytes`. Available options: `keccak256`, `sha256`

> [!NOTE]
>
> You must provide either `hash` OR the combination of `bytes`, `encoding`, and `hash_function`. These parameter sets are mutually exclusive.

## Response

**data** `object` *required*

**child attributes**

**signature** `string`

The signature, prefixed with `0x`.

**encoding** `string`

The encoding of the signature.

**error** `object`

**child attributes**

**code** `string`

The error code.

**message** `string`

The error message.

**NodeJS**

Use the `rawSign` method on the `wallets()` interface to sign a hash or `bytes` (with `encoding` and `hash_function`) with a wallet.

### Usage

```tsx theme={"system"}
const {signature, encoding} = await privy.wallets().rawSign('insert-wallet-id', {
  params: { hash: '0x0775aeed9c9ce6e0fbc4db25c5e4e6368029651c905c286f813126a09025a21e' },
});
```

Alternatively, you can provide bytes to hash with a specific encoding and hash function, and gets a similar response.

```tsx theme={"system"}
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](https://docs.privy.io/api-reference/wallets/raw-sign.md) for more details.

**Java**

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

```java theme={"system"}
try {
    RawSignInput request = RawSignInput.builder()
        .params(
            RawSignInputParams.of(RawSignHashParams.builder()
                .hash("0x0775aeed9c9ce6e0fbc4db25c5e4e6368029651c905c286f813126a09025a21e")
                .build())
        )
        .build();

    // Alternatively, you can provide bytes to hash with a specific encoding and hash function, and gets a similar response.
    /*
      RawSignInput request = RawSignInput.builder()
          .params(
              RawSignInputParams.of(RawSignBytesParams.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().orElse(e.getMessage());
    System.err.println(errorBody);
} catch (Exception e) {
    System.err.println(e.getMessage());
}
```

### Parameters

**request** `RawSignInput` *required*

**params** `RawSignInputParams` *required*

**Option 1: Sign a pre-computed hash**

**hash** `String`

The hex-encoded hash to sign, prefixed with `0x`. Use this option when you have already computed the hash.

**Option 2: Hash bytes before signing**

**bytes** `String`

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`.

**encoding** `String`

The encoding scheme for the bytes. Required when using `bytes`. Available options: `utf-8`, `hex`

**hashFunction** `String`

The hash function to hash the bytes. Required when using `bytes`. Available options: `keccak256`, `sha256`

> [!NOTE]
>
> You must provide either `hash` OR the combination of `bytes`, `encoding`, and `hash_function`. These parameter sets are mutually exclusive.

### Returns

The `WalletRawSignResponse` object contains a `rawSignResponse()` field

**rawSignResponse()** `Optional\<RawSignResponse\>`

**data()** `Optional\<RawSignResponseData\>`

**signature()** `String`

The signature produced by the wallet, prefixed with `0x`.

**Python**

Use the `raw_sign` method on the wallets service.

```python theme={"system"}
response = client.wallets.raw_sign(
    "wallet-id",
    wallet_raw_sign_params={
        "params": {
            "hash": "0x6503b027a625549f7be691646404f275f149d17a119a6804b855bac3030037aa"
        }
    },
)

signature = response.data.signature
```

**Go**

Use the `RawSign` method on the `Wallets` service to sign a raw payload with a wallet on any supported chain.

### Usage

```go theme={"system"}
response, err := client.Wallets.RawSign(
    context.Background(),
    "wallet-id",
    privy.WalletRawSignParams{
        RawSignInput: privy.RawSignInput{
            Params: privy.RawSignInputParamsUnion{
                OfRawSignHashs: &privy.RawSignHashParams{
                    Hash: "0x6503b027a625549f7be691646404f275f149d17a119a6804b855bac3030037aa",
                },
            },
        },
    },
)
if err != nil {
    log.Fatalf("failed to sign: %v", err)
}

fmt.Println("Signature:", response.Data.Signature)
```

### Parameters and Returns

See the [API reference](https://docs.privy.io/api-reference/wallets/raw-sign.md) for more details.

**Ruby**

Use the `raw_sign` method on the `wallets` service to sign a raw payload with a wallet on any supported chain.

### Usage

```ruby theme={"system"}
response = client.wallets.raw_sign(
  "wallet-id",
  raw_sign_input: {
    params: {
      hash: "0x6503b027a625549f7be691646404f275f149d17a119a6804b855bac3030037aa"
    }
  },
  authorization_context: ctx
)

puts(response.data.signature)
```

### Parameters and Returns

See the [API reference](https://docs.privy.io/api-reference/wallets/raw-sign.md) for more details.

**React**

Sign a raw hash or `bytes` (with `encoding` and `hash_function`) along the blockchain's cryptographic curve using the wallet's private key.

```typescript theme={"system"}
signRawHash: ({address: string, chainType: CurveSigningChainType, hash: HexString}) =>
  Promise<{signature: HexString}>;
```

### Usage

```typescript theme={"system"}
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

**opts.address** `string` *required*

The address of the wallet to use for signing the raw hash.

**opts.chainType** `CurveSigningChainType` *required*

The chain type of the wallet to use for signing the raw hash.

**Option 1: Sign a pre-computed hash**

**opts.hash** `HexString`

The raw hash to sign over, hex-encoded and prefixed with `0x`. Use this option when you have already computed the hash.

**Option 2: Hash bytes before signing**

**opts.bytes** `string`

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`.

**opts.encoding** `'utf-8' | 'hex'`

The encoding scheme for the bytes. Required when using `bytes`.

**opts.hashFunction** `'keccak256' | 'sha256'`

The hash function to hash the bytes. Required when using `bytes`.

> [!NOTE]
>
> You must provide either `hash` OR the combination of `bytes`, `encoding`, and `hash_function`. These parameter sets are mutually exclusive.

### Returns

**child properties**

**signature** `HexString`

The signature produced by the wallet. Hex-encoded and prefixed with `0x`.

**React Native**

Sign a raw hash or `bytes` (with `encoding` and `hash_function`) along the blockchain's cryptographic curve using the wallet's private key.

```typescript theme={"system"}
signRawHash: ({address: string, chainType: CurveSigningChainType, hash: HexString}) =>
  Promise<{signature: HexString}>;
```

### Usage

```typescript theme={"system"}
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

**opts.address** `string` *required*

The address of the wallet to use for signing the raw hash.

**opts.chainType** `CurveSigningChainType` *required*

The chain type of the wallet to use for signing the raw hash.

**Option 1: Sign a pre-computed hash**

**opts.hash** `HexString`

The raw hash to sign over, hex-encoded and prefixed with `0x`. Use this option when you have already computed the hash.

**Option 2: Hash bytes before signing**

**opts.bytes** `string`

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`.

**opts.encoding** `'utf-8' | 'hex'`

The encoding scheme for the bytes. Required when using `bytes`.

**opts.hashFunction** `'keccak256' | 'sha256'`

The hash function to hash the bytes. Required when using `bytes`.

> [!NOTE]
>
> You must provide either `hash` OR the combination of `bytes`, `encoding`, and `hash_function`. These parameter sets are mutually exclusive.

### Returns

**child properties**

**signature** `HexString`

The signature produced by the wallet. Hex-encoded and prefixed with `0x`.
