
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
@dioxide-js/silas
Advanced tools
@dioxide-js/silas is a Nodejs/javascript SDK which designed to interact with Dioxide JSON RPC API。
using npm
$ npm install @dioxide-js/silas
using yarn
$ yarn add @dioxide-js/silas
Using pnpm:
$ pnpm add @dioxide-js/silas
Using in browser
<script src="https://unpkg.com/@dioxide-js/silas@latest/dist/umd/index.min.js"></script>
<script>
const { Web3 } = DSSWeb3;
const web3 = new Web3(<DIOSERVICE_ENDPOINT>, {
apiKey: <YOUR_API_KEY>
});
web3.overview.chainStatus().then(console.log)
</script>
import { Web3, NET } from '@dioxide-js/silas'
import { dataview } from '@dioxide-js/misc'
const web3 = new Web3(<DIOSERVICE_ENDPOINT>, {
apiKey: 'YOUR_API_KEY',
}) // const web3 = new Web3(NET.MAIN); // For production
const user0 = {
address: 'jjkw5p9fz7nk0zfy6171ch0dy8bk16mhgpwkdcrc4rpt4sfzpvht9za2qr:sm2',
privatekey: 'AyyogAYL5nVC5CsrTxdYe9IBXOppNqsGd+hSHn+QT68=',
id: 'stest01',
}
const privatekeyU8 = dataview.base64ToU8(user0.privatekey)
To set a proof and retrieve tx hash as result.
const txnHash = await web3.proof.newProof(user0.privatekey, {
content: 'sdk unit test',
key: 'test234',
sender: user0.address,
})
const proofs = await web3.proof.getProofs({
owner: user0.address,
})
const proofs = await web3.proof.checkProof("ctz5ftg90cxm65j3ns5g4f99zezen9a73dkw2s7xspjbg19t4ax0")
const result = await web3.account.generate('sm2')
console.log(result.publickey, result.privatekey, result.address)
const userState = await web3.account.getState({
address: user0.address,
})
console.log(userState)
/* output: {
"address": "a0r0ywzbgntvppvbqwrc6fgfz54f5zq1fme9579bd69j64gvk7f78nmwjm:sm2",
"publickey": "S7dFGoY5TMydWP1+VuSG5+IpmVMv1jbbqwpBJDxIILtUlntfmrONqfPYZ+0GSbHZ4QlSQaUTcqKrPHWV2nqZTQ==",
"status": "0",
"userid": "new_test"
} */
const registed = await web3.account.register({id: user0.id})
const status = await web3.overview.chainStatus()
console.log(status.Throughput) // output: 100.03
Get recently transactions on blockchain.
const list = await web3.overview.getTxHistory()
console.log(list)
const isn = await web3.address.getISN()
console.log(isn) // output: 8
Get the list of transactions related to the address (summary information).
const list = await web3.address.getTxnListByAddress({
address: user0.address
})
const state = await web3.address.getAddressState({address: user0.address})
console.log(state)
const profile = await web3.address.getAddressInfo({
address: user0.address
})
console.log(profile)
const blockList = await web3.block.getHistory({"shardindex": 1})
console.log(blockList)
const tx = await web3.block.getExcutedTx({"height": 100})
console.log(tx)
const detail = await web3.block.detail("mgthswczq1b3ycyvh5t3be01t4trayx4k7s7c09ad1natffhk0w0")
console.log(detail)
const detail = await web3.txn.getTx("a9cdzqythgtn8078ejhghb74f6s8x9k9v0rcn13azt1fp19wcftg")
cosnole.log(detail)
// output:
{
"ISN": 2,
"TTL": 1800000,
"Hash": "a9cdzqythgtn8078ejhghb74f6s8x9k9v0rcn13azt1fp19wcftg",
"Mode": "ITM_FIRST_SIGNER|TGM_USER_SIGNED",
"Size": 181,
...
}
Send a transaction. The transaction will be constructed and signed locally using the private key, and the signed result will be broadcast to the blockchain. The private key will not be transmitted over the network.
const data = aawait web3.txn.send({
args: {
Amount: '200000000',
To: user1.address
},
function: 'core.coin.transfer',
gasprice: '100',
sender: user0.address,
}, user0.privatekey)
console.log(data) // output: "5akjfknj9phq93r56kqygjcv3r1tpwm2gt82xex1z3nkrk4r509g"
see src/api/type.ts
link
FAQs
RPC utility for Silas
We found that @dioxide-js/silas demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.