Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
83 lines (67 sloc) 1.96 KB
Sample Crowdfunding AT code written in ATScript for BURST AT (Automated Transactions aka Smart Contracts)
See more at
Compare this ATScript to its functional equivalent written in AT assembler
at to see why ATScript is needed
var timestamp;
var decision_time;
var txid;
var tx_amt;
var target_amt;
var target_acc;
var balance;
var tx_source;
var refund_time;
function funded(){
//send all money to target_account
AT.transfer(balance, target_acc);
function refund(){
//find first transaction after creation of AT
timestamp = refund_time;
txid = AT.getFirstTxAfterTimestamp(timestamp);
timestamp = AT.getTxTimestamp(txid);
//loop through all transaction
while (txid) {
if (AT.getTxTarget(txid) == AT.getAddress()){
//give back any money transfered to AT
tx_source = AT.getTxSource(txid);
tx_amt = AT.getTxAmount(txid);
AT.transfer(tx_amt, tx_source);
//get next transaction
txid = AT.getFirstTxAfterTimestamp(timestamp);
timestamp = AT.getTxTimestamp(txid);
function makeDecision(){
//get current AT balance
balance = AT.getBalance();
//if we don't have enough
if (balance < target_amt){
} else {
timestamp = AT.getBlockTimestamp();
refund_time = timestamp;
decision_time = timestamp + 14*24*60*4; //decision_time in 14 days
target_amt = 10000;
target_acc = '...';
//loop function will be run multiple times after deployment of AT
AT.loop(function () {
//loop through all transactions after creation of AT
txid = AT.getFirstTxAfterTimestamp(timestamp);
if (txid) {
//update timestamp to transaction time
timestamp = AT.getTxTimestamp(txid);
//if time is up
if(timestamp > decision_time){
You can’t perform that action at this time.