区块链 API OptimismJSON-RPC methods The standard Ethereum methods documented here are supported by Chainup Cloud on the Optimism network.
Optimism RPC
You can review custom methods specific to Optimism can be found in the official Optimism API documentation .
Example RPC
Curl Javascript Python
Copy curl https://api.chainup.net/optimism/mainnet/<YOUR_API_KEY> \
-X POST \
-H 'content-type: application/json' \
-H "CONSISTENT-HASH: true" \
--data '{"jsonrpc":"2.0","method":"getblockchaininfo","params":[],"id":1}'
Copy ```javascript
const axios = require('axios');
//npm install axios if you don have the module installed`
let options = {
url : "https://api.chainup.net/optimism/mainnet/<YOUR_API_KEY>" ,
method : "post" ,
headers :
{
"content-type" : "application/json" ,
"CONSISTENT-HASH" : "true"
} ,
body : JSON .stringify ({ "jsonrpc" : "2.0" , "method" : "getblockchaininfo" , "params" : [] , "id" : 1 })
};
request (options , (error , response , body) => {
if (error) {
console .error ( 'An error has occurred: ' , error);
} else {
console .log ( 'Post successful: response: ' , body);
}
});
```
Copy import requests
import json
headers = { "content-type" : "application/json" ,
"CONSISTENT-HASH" : "true" }
payload = json . dumps ({
"id" : 1 ,
"jsonrpc" : "2.0" ,
"method" : "getblockchaininfo" ,
"params" : []
})
r = requests . post (url = "https://api.chainup.net/optimism/mainnet/<YOUR_API_KEY>" , headers = headers, data = payload)
if r . status_code == 200 :
print ( "Post successful: response: " , r.content)
else :
print ( "An error has occurred: " , r.status_code)