Skip to content

Instantly share code, notes, and snippets.

@kalepail
Last active August 25, 2023 04:11
Show Gist options
  • Save kalepail/c5618b7be4b05f891ffebdae9d144326 to your computer and use it in GitHub Desktop.
Save kalepail/c5618b7be4b05f891ffebdae9d144326 to your computer and use it in GitHub Desktop.
A really easy way to get started with smart contracts on Turing Sign Servers is to upload the code below changing the `hostname` to link to an endpoint where your actual contract logic lives. This allows you to change and modify your contract logic freely. Great for testing before locking in a more immutable contract state.
const { request } = require('https')
module.exports = (body) =>
new Promise((resolve, reject) => {
try {
body = JSON.stringify(body)
const options = {
hostname: 'contract-logic-endpoint.io', // runkit and glitch are my goto services
port: 443,
path: '/',
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Content-Length': body.length,
},
}
const req = request(options, (res) => {
let data = ''
res.on('data', (chunk) => data += chunk)
res.on('end', () => resolve(data))
})
req.on('error', (err) => reject(err))
req.write(body)
req.end()
} catch (err) {reject(err)}
})
.catch((err) => {throw err})
@mistychatmsn
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment