Skip to content

Instantly share code, notes, and snippets.

View KardanovIR's full-sized avatar
🥸
Focusing

Inal Kardanov KardanovIR

🥸
Focusing
View GitHub Profile
pragma solidity ^0.5.11;
contract HelloWorld {
uint public myFavoriteNumber = 1610;
//define a new variable "yourFavoriteNumber" here
function myFavoriteNumberPlusYourFavoriteNumber() public view returns (uint) {
return myFavoriteNumber + yourFavoriteNumber;
}
@Callable(i)
func refundUser(id: Int) = {
# receiving campaign parameters
let endTimestamp = getIntegerValue(this, keyEndTimestamp(id))
let targetSum = getIntegerValue(this, keyTargetSum(id))
let raised = getIntegerValue(this, keyRaised(id))
# receiving the number of tokens sent by the current investor
let fundedAmount = getIntegerValue(this, keyUserFunded(id, i.callerPublicKey.toBase58String()))
@Callable(i)
func voteForRelease(id: Int) = {
# receiving campaign parameters
let endTimestamp = getIntegerValue(this, keyEndTimestamp(id))
let implEndTimestamp = getIntegerValue(this, keyImplEndTimestamp(id))
let votePower = getIntegerValue(this, keyUserFunded(id, i.callerPublicKey.toBase58String()))
let targetSum = getIntegerValue(this, keyTargetSum(id))
let raised = getIntegerValue(this, keyRaised(id))
let released = getBooleanValue(this, keyReleasedTokens(id))
@Callable(i)
func fund(id: Int) = {
# receiving an attached payment; if there is no payment, an exception will be created
let pmt = i.payments[0].extract()
# receiving campaign parameters
let targetSum = getIntegerValue(this, keyTargetSum(id))
let endTimestamp = getIntegerValue(this, keyEndTimestamp(id))
let owner = getStringValue(this, keyOwner(id))
func keyFunding (id: Int) = "funding_" + id.toString()
func keyEndTimestamp(id: Int) = keyFunding(id) + "_timestamp"
func keyImplEndTimestamp(id: Int) = keyFunding(id) + "_impl_timestamp"
func keyTargetSum(id: Int) = keyFunding(id) + "_targetSum"
func keyOwner(id: Int) = keyFunding(id) + "_owner"
func keyRaised(id: Int) = keyFunding(id) + "_raised"
func keyReleaseVotes(id: Int) = keyFunding(id) + "_release_votes"
func keyReleasedTokens(id: Int) = keyFunding(id) + "_released"
@Callable(i)
func startFunding(id: Int, fundraisingEndTimestamp: Int, implmenetationEndTimestamp: Int, targetSum: Int) = {
# current time
let lastBlockTimestamp = lastBlock.timestamp
# The campaign end cannot be less than 60 seconds
if (fundraisingEndTimestamp - lastBlockTimestamp - 60 < 0) then throw("End time should at least 60 seconds more than the last block time") else
# The campaign end time cannot be less than the project execution time
if (implmenetationEndTimestamp < fundraisingEndTimestamp) then throw("Implementation end time should more or equal to endTimestamp") else
{-# STDLIB_VERSION 4 #-}
{-# CONTENT_TYPE EXPRESSION #-}
{-# SCRIPT_TYPE ACCOUNT #-}
# specifying the ID of a token issued for this team
let assetId = base58'...'
# the address of an account in which the dApp and team members’ account list will be stored
let whiteListAddress = "..."
match tx {
{-# STDLIB_VERSION 4 #-}
{-# CONTENT_TYPE DAPP #-}
{-# SCRIPT_TYPE ACCOUNT #-}
let adminPublicKey = base58'...'
func addToWhiteList(address: String) = {
let userInTheList = getBoolean(this, address)
let newValue = match userInTheList {
const adminSeed = '...';
const issueTx = issue({
name: `Thanks`,
description: 'Say thank you to all of your teammates in Slack. By Billy.',
decimals: 0,
quantity: 100000000,
reissuable: false
}, adminSeed);
await broadcast(issueTx);
@Callable(i)
func takeReward(id: String) = {
if (keyIsDefined(id) == false) then throwIdError(id) else {
let paymentValue = getIntegerValue(this, keyPayment(id))
let oraclePubKey = i.callerPublicKey.toBase58String()
let oracleResponseKey = keyResponseFromOracle(id, oraclePubKey)
let oracleResponse = getStringValue(this, oracleResponseKey)
let resultKey = keyResult(id)
let resultDataEntry = getStringValue(this, resultKey)