bdcontract-sdk-javascript/test/ws.html
2023-03-15 10:07:21 +08:00

56 lines
1.3 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<script src="./sm2.js"></script>
<script src="./cryptico.iife.js"></script>
<script src="../lib/index.js"></script>
<script>
function print(string) {
document.write(`${string}\n\n`)
}
const url = 'ws://127.0.0.1:18000/SCIDE/SCExecutor'
const client = new bdcontract.WsClient(
url,
(ev) => {
console.log("onOpen:"+JSON.stringify(ev))
invokeContract()
},
(ev, ws) => {
console.log(ev.data)
},
)
function invokeContract(){
setTimeout(async () => {
const status = client.status()
console.log(status)
try {
let data = await client.executeContract(
'AnnotationExample0608',
'main',
'abacd',
)
print(JSON.stringify(data))
data = await client.executeContract(
'NonExistentContract',
'random',
'abacd',
)
print(JSON.stringify(data))
} catch (data) {
print(JSON.stringify(data))
}
}, 1000)
}
</script>
<link rel="icon" type="image/svg+xml" href="favicon.svg"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Vite App</title>
</head>
<body></body>
</html>