Skip to main content

author_submitExtrinsic - JSON-RPC Method

Description​

Submits a fully formatted and signed extrinsic (transaction) to the Polkadot network's transaction pool for inclusion in a block. This method is essential for broadcasting transactions to the network.

Parameters​

ParameterTypeRequiredDescription
extrinsicstringYesHex-encoded signed extrinsic to submit to the network

Returns​

FieldTypeDescription
resultstringTransaction hash of the submitted extrinsic

Request Example​

{
"jsonrpc": "2.0",
"method": "author_submitExtrinsic",
"params": [
"0x450284008eaf04151687736326c9fea17e25fc5287613693c912909cb226aa4794f26a480284d717d5031504025a62020b00000000000000e143f23803ac50e8f6f8e62695d1ce9e4e1d68aa36c1cd2cfd15340213f3423e3aedc952073c01f1c4d76ccd8c18d0f900fcb6ac003a5f08709e3c9038b68055"
],
"id": 1
}

Response Example​

{
"jsonrpc": "2.0",
"result": "0x7c8b4d5a6f2e3c9d8a7b5e4f3c2d1a9b8c7e6f5d4c3b2a1",
"id": 1
}

Code Examples​

cURL​

curl https://api-polkadot.n.dwellir.com \
-X POST \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "author_submitExtrinsic",
"params": ["0x450284..."],
"id": 1
}'

JavaScript (fetch)​

const submitExtrinsic = async (signedExtrinsic) => {
const response = await fetch('https://api-polkadot.n.dwellir.com', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
jsonrpc: '2.0',
method: 'author_submitExtrinsic',
params: [signedExtrinsic],
id: 1
})
});

const data = await response.json();
return data.result; // Transaction hash
};

// Example usage
const txHash = await submitExtrinsic('0x450284...');
console.log('Transaction submitted:', txHash);

Python (requests)​

import requests
import json

def submit_extrinsic(signed_extrinsic):
url = "https://api-polkadot.n.dwellir.com"
headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
}

payload = {
"jsonrpc": "2.0",
"method": "author_submitExtrinsic",
"params": [signed_extrinsic],
"id": 1
}

response = requests.post(url, headers=headers, data=json.dumps(payload))
data = response.json()

if "error" in data:
raise Exception(f"RPC Error: {data['error']}")

return data["result"]

# Example usage
tx_hash = submit_extrinsic("0x450284...")
print(f"Transaction submitted: {tx_hash}")

TypeScript (@polkadot/api)​

import { ApiPromise, WsProvider } from '@polkadot/api';
import { Keyring } from '@polkadot/keyring';

async function submitTransaction() {
// Connect to node
const provider = new WsProvider('wss://api-polkadot.n.dwellir.com');
const api = await ApiPromise.create({ provider });

// Create keyring and add account
const keyring = new Keyring({ type: 'sr25519' });
const alice = keyring.addFromUri('//Alice');

// Create and sign transaction
const transfer = api.tx.balances.transfer(
'RECIPIENT_ADDRESS',
1000000000000 // 1 DOT (10^12 planck)
);

// Sign and submit
const hash = await transfer.signAndSend(alice);
console.log('Transaction hash:', hash.toHex());

// Alternatively, submit pre-signed extrinsic
const signedExtrinsic = transfer.sign(alice);
const txHash = await api.rpc.author.submitExtrinsic(signedExtrinsic);
console.log('Submitted via RPC:', txHash.toHex());
}

Use Cases​

  1. Token Transfers: Submit balance transfer transactions
  2. Staking Operations: Delegate, bond, or unbond DOT tokens
  3. Governance: Submit votes, proposals, or referenda
  4. Smart Contract Calls: Execute contract methods
  5. Parachain Operations: Cross-chain message passing

Error Handling​

Common Errors​

Error CodeDescriptionSolution
-32602Invalid extrinsic formatEnsure extrinsic is properly hex-encoded
-32603Invalid signatureVerify the extrinsic is correctly signed
1010Invalid transactionCheck nonce, mortality period, and account balance
1012Transaction pool fullRetry with higher priority fee
1013Already in poolTransaction already submitted

Error Response Example​

{
"jsonrpc": "2.0",
"error": {
"code": 1010,
"message": "Invalid Transaction",
"data": "Inability to pay some fees (e.g. account balance too low)"
},
"id": 1
}

Best Practices​

  1. Nonce Management: Always use the correct nonce to avoid transaction rejection
  2. Fee Estimation: Calculate fees before submission using payment_queryFeeDetails
  3. Mortality Period: Set appropriate mortality period for time-sensitive transactions
  4. Error Handling: Implement robust error handling for network issues
  5. Transaction Monitoring: Track transaction status after submission

Notes​

  • Extrinsics must be properly formatted and signed before submission
  • The transaction hash returned is not a guarantee of inclusion in a block
  • Monitor transaction status using subscription methods for critical operations
  • Different transaction types require different encoding based on runtime metadata