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/rpcTo interact with other instances of the EVM via the JSON-RPC endpoint:
/ext/bc/blockchainID/rpcwhere blockchainID is the ID of the blockchain running the EVM.
WebSocket Endpointsβ
To interact via the websocket endpoint:
/ext/bc/C/wsFor 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/wsTo interact with other instances of the EVM via the websocket endpoint:
/ext/bc/blockchainID/wswhere 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}addressowner of the assetblkis the block number or hash at which to retrieve the balanceassetIDid 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/rpcExample 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/rpcExample 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/rpcExample 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/rpcExample 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
codetab selectverify & publishCopy 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