Skip to content

Instantly share code, notes, and snippets.

View stablearc's full-sized avatar
🎯
Focusing

Arc stablearc

🎯
Focusing
View GitHub Profile
$ exit
$ docker container ls -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8cfa3f87b3c4 iconloop/tbears "entry.sh" About an hour ago Up 42 minutes 0.0.0.0:9000->9000/tcp local-tbears
$ docker run -it --name local-tbears -p 9000:9000 iconloop/tbears
...
...
Started tbears service successfully
@app.route('/file', methods=["POST"])
def upload_file():
if "user_file" not in request.files:
return "No user_file key in request.files"
file = request.files["user_file"]
if file.filename == "":
return "Please select a file"
# get url from s3
output = upload_to_aws_s3(file, S3_BUCKET)
return str(output)
def upload_to_aws_s3(file):
s3.upload_fileobj(
file,
S3_BUCKET,
file.filename,
ExtraArgs={
"ACL": acl
"ContentType": file.content_type
}
)
import boto3
# AWS Creds
S3_BUCKET = "BUCKET_NAME"
S3_KEY = "BUCKET_ACCESS_KEY"
S3_SECRET = "BUCKET_SECRET_KEY"
# Create boto3 client connection
s3 = boto3.client(
"s3",
pip3 install boto3
EOSIO_DISPATCH( eosio::token, (create)(issue)(transfer) )
void token::transfer( name from,
name to,
asset quantity,
string memo )
{
eosio_assert( from != to, "cannot transfer to self" );
require_auth( from );
eosio_assert( is_account( to ), "to account does not exist");
auto sym = quantity.symbol.code();
stats statstable( _self, sym.raw() );
void token::issue( name to, asset quantity, string memo )
{
auto sym = quantity.symbol;
eosio_assert( sym.is_valid(), "invalid symbol name" );
eosio_assert( memo.size() <= 256, "memo has more than 256 bytes" );
stats statstable( _self, sym.code().raw() );
auto existing = statstable.find( sym.code().raw() );
eosio_assert( existing != statstable.end(), "token with symbol does not exist, create token before issue" );
void token::create( name issuer,
asset maximum_supply )
{
require_auth( _self );
auto sym = maximum_supply.symbol;
eosio_assert( sym.is_valid(), "invalid symbol name" );
eosio_assert( maximum_supply.is_valid(), "invalid supply");
eosio_assert( maximum_supply.amount > 0, "max-supply must be positive");