eth_sign - BSC

The eth_sign method requires the account to be unlocked on the node. It is not available on public RPC endpoints. Use client-side signing libraries (e.g., ethers.js, viem) for signing when using public RPCs.

The eth_sign method calculates an Ethereum-specific signature for the given data.

Parameters

ParameterTypeRequiredDescription
addressstringYesAddress to sign with
messagestringYesData to sign (hex)

Returns

FieldTypeDescription
resultstringSignature (65 bytes hex)

Request Example

curl

bashcurl --location --request POST 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "eth_sign",
    "params": [
        "0x8D97689C9818892B700e27F316cc3E41e17fBeb9",
        "0x48656c6c6f20576f726c64"
    ],
    "id": "getblock.io"
}'

example.js

javascriptconst axios = require('axios');

const url = 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/';

const payload = {
    jsonrpc: '2.0',
    method: 'eth_sign',
    params: [
        '0x8D97689C9818892B700e27F316cc3E41e17fBeb9',
        '0x48656c6c6f20576f726c64'
    ],
    id: 'getblock.io'
};

axios.post(url, payload, {
    headers: { 'Content-Type': 'application/json' }
})
.then(response => console.log(response.data))
.catch(error => console.error(error));

example.py

pythonimport requests

url = "https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/"

payload = {
    "jsonrpc": "2.0",
    "method": "eth_sign",
    "params": [
        "0x8D97689C9818892B700e27F316cc3E41e17fBeb9",
        "0x48656c6c6f20576f726c64"
    ],
    "id": "getblock.io"
}

response = requests.post(url, headers={"Content-Type": "application/json"}, json=payload)
print(response.json())

main.rs

rustuse reqwest::Client;
use serde_json::json;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::new();
    
    let payload = json!({
        "jsonrpc": "2.0",
        "method": "eth_sign",
        "params": [
            "0x8D97689C9818892B700e27F316cc3E41e17fBeb9",
            "0x48656c6c6f20576f726c64"
        ],
        "id": "getblock.io"
    });

    let response = client
        .post("https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/")
        .header("Content-Type", "application/json")
        .json(&payload)
        .send()
        .await?;

    let result: serde_json::Value = response.json().await?;
    println!("{:#?}", result);
    
    Ok(())
}

Response Example

response.json

json{
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "error": {
        "code": -32000,
        "message": "unknown account"
    }
}

Response Parameters

ParameterTypeDescription
resultstringSignature (if supported)
errorobjectError for public RPCs

Use Cases

  • Message signing (local nodes)
  • Authentication systems
  • Off-chain signatures

Error Handling

Error CodeDescription
-32601Method not supported
-32000Account not unlocked

SDK Integration

ethers.js

javascriptconst { ethers } = require('ethers');

// Sign locally with wallet
const wallet = new ethers.Wallet(privateKey);

const message = 'Hello World';
const signature = await wallet.signMessage(message);
console.log('Signature:', signature);

viem.js

javascriptimport { privateKeyToAccount } from 'viem/accounts';

const account = privateKeyToAccount('0x...');

const signature = await account.signMessage({
    message: 'Hello World'
});
console.log('Signature:', signature);