Smart Contract
Building Non-Stop
Deploy Smart Contract
Ethereum APIs
JSON-RPC Endpoints
To interact with C-Chain via the JSON-RPC endpoint:
/ext/bc/C/rpc
To interact with other instances of the EVM via the JSON-RPC endpoint:
/ext/bc/blockchainID/rpc
where blockchainID
is the ID of the blockchain running the EVM.
WebSocket Endpoints
To interact via the websocket endpoint:
/ext/bc/C/ws
For example, to interact with the C-Chain's Ethereum APIs via websocket on localhost you can use:
ws://127.0.0.1:9650/ext/bc/C/ws
To interact with other instances of the EVM via the websocket endpoint:
/ext/bc/blockchainID/ws
where blockchainID
is the ID of the blockchain running the EVM.
Standard Ethereum APIs
GEMNODE offers an API interface identical to Geth's API except that it only supports the following services:
web3_
net_
eth_
personal_
txpool_
debug_
(note: this is turned off on the public api node.)
You can interact with these services the same exact way you’d interact with Geth. See the Ethereum Wiki’s JSON-RPC Documentation and Geth’s JSON-RPC Documentation for a full description of this API.
eth_getAssetBalance
In addition to the standard Ethereum APIs, Avalanche offers eth_getAssetBalance
to retrieve the balance of first class Avalanche Native Tokens on the C-Chain (excluding AVAX, which must be fetched with eth_getBalance
).
Signature
eth_getAssetBalance({
address: string,
blk: BlkNrOrHash,
assetID: string,
}) -> {balance: int}
address
owner of the assetblk
is the block number or hash at which to retrieve the balanceassetID
id of the asset for which the balance is requested
Example Call
curl -X POST --data '{
"jsonrpc": "2.0",
"method": "eth_getAssetBalance",
"params": [
"0x8723e5773847A4Eb5FeEDabD9320802c5c812F46",
"latest",
"3RvKBAmQnfYionFXMfW5P8TDZgZiogKbHjM8cjpu16LKAgF5T"
],
"id": 1
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/C/rpc
Example Response
{ "jsonrpc": "2.0", "id": 1, "result": "0x1388"}
eth_baseFee
Get the base fee for the next block.
Signature
eth_baseFee() -> {}
result
is the hex value of the base fee for the next block.
Example Call
curl -X POST --data '{
"jsonrpc":"2.0",
"id" :1,
"method" :"eth_baseFee",
"params" :[]
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/C/rpc
Example Response
{ "jsonrpc": "2.0", "id": 1, "result": "0x34630b8a00"}
eth_maxPriorityFeePerGas
Get the priority fee needed to be included in a block.
Signature
eth_maxPriorityFeePerGas() -> {}
result
is hex value of the priority fee needed to be included in a block.
Example Call
curl -X POST --data '{
"jsonrpc":"2.0",
"id" :1,
"method" :"eth_maxPriorityFeePerGas",
"params" :[]
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/C/rpc
Example Response
{ "jsonrpc": "2.0", "id": 1, "result": "0x2540be400"}
For more information on dynamic fees see the C-Chain section of the transaction fee documentation.
eth_getChainConfig
eth_getChainConfig
returns chain config. This API is enabled by default with internal-eth
namespace.
Signature
eth_getChainConfig({}) -> {chainConfig: json}
Example Call
curl -X POST --data '{
"jsonrpc":"2.0",
"id" :1,
"method" :"eth_getChainConfig",
"params" :[]
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/C/rpc
Example Response
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"chainId": 43112,
"homesteadBlock": 0,
"daoForkBlock": 0,
"daoForkSupport": true,
"eip150Block": 0,
"eip150Hash": "0x2086799aeebeae135c246c65021c82b4e15a2c451340993aacfd2751886514f0",
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
"istanbulBlock": 0,
"muirGlacierBlock": 0,
"apricotPhase1BlockTimestamp": 0,
"apricotPhase2BlockTimestamp": 0,
"apricotPhase3BlockTimestamp": 0,
"apricotPhase4BlockTimestamp": 0,
"apricotPhase5BlockTimestamp": 0
}
}
GEMNODE Specific APIs
Coming Soon!
Verify Smart Contract
Contract Verification
Smart contract verification provides transparency by publishing the source code, allowing everyone to attest that it really does what it claims to do. You can verify your smart contracts using the GEMNODE Explorer. The procedure is simple:
Navigate to your published contract address on the explorer
On the
code
tab selectverify & publish
Copy and paste the flattened source code and enter all the build parameters exactly as they are on the published contract
Click
verify & publish
If successful, the code
tab will now have a green checkmark, and your users will be able to verify the contents of your contract. This is a strong positive signal that your users can trust your contracts, and it is strongly recommended for all production contracts.
Contract Security Checks
Once deployed, it would be tough to fix bugs on decentralized applications due to its nature. Hence, it's vital to ensure an app operates properly before deployment. Contract security reviews can be done by specialized companies and services, but they will be costly. To avoid paying sky high audit fees, developers can use free resources as Slither, MythX, Mythril.
Last updated