Last active
August 25, 2023 04:11
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
commented
May 28, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment