SOLNM
  • Introduction
  • Technology
    • CMv3 & UI
    • Dapp
    • Wallet adapter
    • WebSockets
    • React app
    • Web3.js
    • Metaplex
    • Mpl Candy Machine
    • JSON-RPC
    • Geyser plugin postgres
  • Drops
    • Basic Drop
    • Plus Drop
    • Advanced Drop
  • NFT Tickets solution
  • NFT Payments
  • Collect Whitelists
  • NFT assets
  • Fees and Commission
  • SOLPAD PASS
  • SOLNM SPL Token
  • Airdrop
  • Whitepaper
  • Roadmap
  • FAQ
  • Terms
  • Privacy
  • Jobs
    • Affiliate Marketing
  • Linkedin
  • Twitter
  • Telegram
  • Discord
  • Github
Powered by GitBook
On this page
  1. Technology

JSON-RPC

PreviousMpl Candy MachineNextGeyser plugin postgres

Last updated 1 year ago

Rust implementation of JSON-RPC 2.0 Specification. Transport-agnostic core and transport servers for http, ipc, websockets and tcp.

extern crate jsonrpc_core;
extern crate jsonrpc_minihttp_server;

use jsonrpc_core::{IoHandler, Value, Params};
use jsonrpc_minihttp_server::{ServerBuilder};

fn main() {
	let mut io = IoHandler::new();
	io.add_method("say_hello", |_params: Params| {
		Ok(Value::String("hello".to_string()))
	});

	let server = ServerBuilder::new(io)
		.threads(3)
		.start_http(&"127.0.0.1:3030".parse().unwrap())
		.unwrap();

	server.wait().unwrap();
}
extern crate jsonrpc_core;
#[macro_use]
extern crate jsonrpc_macros;

use jsonrpc_core::Result;

build_rpc_trait! {
	pub trait Rpc {
		/// Adds two numbers and returns a result
		#[rpc(name = "add")]
		fn add(&self, u64, u64) -> Result<u64>;
	}
}

pub struct RpcImpl;
impl Rpc for RpcImpl {
	fn add(&self, a: u64, b: u64) -> Result<u64> {
		Ok(a + b)
	}
}


fn main() {
	let mut io = jsonrpc_core::IoHandler::new();
	io.extend_with(RpcImpl.to_delegate())
}
Fork from