Smart contracts in Racket

390 views
Skip to first unread message

Beatriz Moreira

unread,
Mar 15, 2021, 7:01:51 PM3/15/21
to Racket Users
Hello! I recently used Racket as a tool to see the small step execution of some smart contract languages and I was wondering if there is anywhere i can submit my work or share it with the Racket community.
Thank you in advance!
Beatriz

James Platt

unread,
Mar 16, 2021, 2:22:44 PM3/16/21
to Racket Users

On Mar 15, 2021, at 7:01 PM, Beatriz Moreira wrote:

> Hello! I recently used Racket as a tool to see the small step execution of some smart contract languages and I was wondering if there is anywhere i can submit my work or share it with the Racket community.

One place might be the Racket Artifacts site. I think it's mainly intended for short demonstrations of code but, if yours is not too long, that might be the place.

https://github.com/racket/racket/wiki/Artifacts

I am interested in smart contracts, as well, for a possible future addition to a project I am working on but it will be a while before I get to that point.

Christopher Lemmer Webber

unread,
Mar 16, 2021, 3:24:35 PM3/16/21
to James Platt, racket...@googlegroups.com
Spritely Goblins is probably what you want to look at, or will after the
next release (v0.8) comes out:

https://docs.racket-lang.org/goblins/index.html

In the not too distant future, Spritely and Agoric's CapTP should
converge. Agoric's current work is all based around smart contracts:

https://agoric.com/
https://github.com/Agoric/agoric-sdk/issues/1827

There's a lot of confusion out there about what "smart contracts" mean;
most of the examples tend to assume it has to do with blockchains. In
fact, work on smart contracts precedes blockchains by several decades.
If you look at http://www.erights.org/ on which many of the ideas in
Spritely Goblins is based, you'll notice that it has the word "smart
contracts" prominently, yet this was well over a decade before
blockchains even existed. What the heck?

Smart contracts as something implemented with distributed objects can be
best understood probably by reading Capability Based Financial Instruments:

http://erights.org/elib/capability/ode/index.html

The mint example from that paper is implemented in Goblins:

https://gitlab.com/spritely/goblins/-/blob/dev/goblins/actor-lib/simple-mint.rkt

That's right, in about 25 lines of Goblins code you can have a
functioning bank of sorts, which preserves financial integrity and even
permits networked accounts. No blockchain required.

Yet, you could add a blockchain, or even turn Goblins into a blockchain
if you wanted. (Since Goblins' actor state is transactional and
snapshottable, you can have a merkle tree of all inputs, and global
consensus on the set of messages accepted by the network, and all
participants can replay and simulate the same abstract machine. This is
fairly trivial to do in Goblins.)

But more interestingly, Agoric has already done the work of abstracting
even remote blockchains as abstract machines on the network. Since
we'll be implementing the same CapTP, when the time comes you'll be able
to access all that for free, even though Agoric programs are written in
Javascript and Goblins programs in Racket.

Anyway, the next release of Goblins, coming soon, should allow for
beginning to play with this kind of stuff on the network more easily
than in the present (v0.7) stuff, which currently takes a lot of work.
So maybe if you can wait a few weeks, it'll be easier to talk about.

But "smart contracts" is a use case, a broad problem domain. What kind
of smart contracts are you wanting to write?

- Chris

James Platt

unread,
Mar 18, 2021, 4:33:50 PM3/18/21
to Racket Users

On Mar 16, 2021, at 3:24 PM, Christopher Lemmer Webber wrote:

> But "smart contracts" is a use case, a broad problem domain. What kind
> of smart contracts are you wanting to write?

I do need to research the topic a bit to make sure that what I want to do is possible but, according to what I understand so far, it's actually a clearer use case for smart contracts than most. I want to use them to promote reproducibility of scientific data analysis. The idea would be that you put your data analysis together as a smart contract and then others can run it again and be much better assured of getting the same result than they would be without the smart contract. As I understand it, one of the big issues with smart contracts for work transactions is that there could be a bug which causes your contract to enforce something a bit differently than you intended. This is quite different from traditional business contracts where, if it comes to a lawsuit, the courts will look for the intent of the contract. My use case is only asking for reproducibility.

The big difficulty for my use case is that you have to be able to tie into various different bits of code previously published by others. For example, a DNA sequencing analysis pipeline which I worked with, had various parts of the process written in Perl, Python, C, R, JAVA, javascript, UNIX shell script, and AppleScript, much of it published by people outside my lab. So a lot of that would probably have to be outside the contract. However, you need a "glue language" to put it all together. We were using shell script for that because most of it needs to run on a supercomputing cluster. We looked for something that could make the code more understandable. Python was a possibility but we were leaning towards Big Data Script (BDS) which is a DSL specifically for this purpose. In any case, if something like BDS (as a glue language) were implemented as a smart contract language, that would at least take care of the top level.

Later on, it would be great to be able to buy and sell resources on our P2P network with a cryptocurrency. This would include storage, bandwidth, and processing time for intensive computations. You would be able to buy and sell smart contracts using these things. I understand that Etherium can do things like this but there are quite a few technologies to read up on, starting with Subutai, https://subutai.io.

Christopher Lemmer Webber

unread,
Mar 18, 2021, 5:25:58 PM3/18/21
to James Platt, racket...@googlegroups.com
You may enjoy reading the "72 Hours to DonutLab" writeup.

https://www.hpl.hp.com/techreports/2005/HPL-2005-5.html

Again, pre-blockchains. This is using the E programming language on
which Spritely is based. As you can see, it's even listed on the E
website under "smart contracts":

http://www.erights.org/smart-contracts/index.html

As for running external programs, these can be contained; SandStorm did
a nice demonstration of how to do this. Guix Workflow Language might
also be an interesting source of inspiration, even though I'm not
suggesting it exactly be what you use.

However, I'd be cautious about drinking too deeply into the blockchain
hype; the things you'd like to accomplish can probably be accomplished
just as well with an E-style mint, as I referenced earlier. But yes,
you can compose blockchains with this too... but more importantly, the
abstraction layer can be *general* enough to not use a *specific* choice
of a cryptocurrency approach. Beware of someone trying to sell you
otherwise on some ICO.

The way that blockchains can just be perceived as mutually-executed
machines on the network (in that sense, "decentralized centralization"
converging on a single machine in the network, reproduced in multiple
places) is probably best explained by this talk:

https://www.youtube.com/watch?v=YXUqfgdDbr8

With the abstractions Mark talks about in that talk (ERTP), you can use
a blockchain... but also plenty of non-blockchain components which might
work just as well for your usecase. But then you haven't tied yourself
to a specific approach. Generalize appropriately.

- Chris

Beatriz Moreira

unread,
Mar 25, 2021, 11:39:22 AM3/25/21
to Racket Users
Hello!
My code is a bit long. I formalised two languages for smart contracts, with a typechecker, so this might not be for me :D but thank you!

Beatriz Moreira

unread,
Mar 25, 2021, 11:44:09 AM3/25/21
to Racket Users
Hi!
Thank you for the Goblins idea, but that's not really what I have in mind.
What I did in Racket was a formalisation of two smart contract core languages, to be able to see the execution step-by-step.
What I had in mind was something like a git where I could publish my work for case study purposes. 
Thank you :D

Adam Golding

unread,
Apr 19, 2021, 3:42:50 AM4/19/21
to Beatriz Moreira, Racket Users
Beatri please tell us more and publish to Github :-)  It seems to me that some racketers should enter the https://moralis.io/hackathon/ to make racket contracts work across other smart contract systems, as this platform has already done some of the boring leg work, otherwise, how will the idea of a 'racket web server' adapt to the needs of a web3 site that interfaces with smart contracts on multiple blockchains?

--
You received this message because you are subscribed to the Google Groups "Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to racket-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/6066d33f-f6e5-44ed-bed9-edda173b15c2n%40googlegroups.com.

Adam Golding

unread,
Apr 19, 2021, 4:16:40 AM4/19/21
to Beatriz Moreira, Racket Users

Adam Golding

unread,
Apr 19, 2021, 8:58:55 PM4/19/21
to Beatriz Moreira, Racket Users
I was just told this topic is off-topic on the racket discord--clearly an injustice:

image.png

Adam Golding

unread,
Apr 20, 2021, 4:21:29 AM4/20/21
to Beatriz Moreira, Racket Users

Stephen De Gabrielle

unread,
Apr 20, 2021, 10:47:04 AM4/20/21
to Racket Users
Dear all,  

I write to apologise for my behaviour. 

I inappropriately deleted a post and subsequent discussion from the Racket Discord. 

I believe this community is for all kinds of developers making all kinds of programs with Racket, and I want everyone to feel welcome to participate in ways that suit them. 

Kind regards

Stephen

Adam Golding

unread,
Apr 20, 2021, 2:29:58 PM4/20/21
to Stephen De Gabrielle, Racket Users
Thanks Stephen, perhaps you can help get the ball rolling again--I had written to suggest that racketers may want to enter the moralis hackathon as there are some points of convergence:

- racket seeks to bridge multiple languages, moralis seeks to bridge multiple blockchains with different smart contract languages
- racket has a powerful contract system which will ultimately need to interoperate with smart contracts 
- racket is aimed at web applications as one use case and moralis is first (I think) in what will be many CMS-type platforms for the new web3 paradigm--if racket does not have a web3 solution it will be left behind and it is already not widely used for web servers--this is an opportunity for the Racket community to front-run the web development industry, get it?

I am not an experienced racketer but I would be happy to help out.  I also got Mr. Ivan to create an #off-topic in the moralis discord for brainstorming that is not strictly development, by analogy to how freenode has both #math and #not-math.  I also suggest the racket discord create a channel specifically for decentralized systems of all kinds--torrents, web3, crypto, voting systems, markets, etc.

Cheers,
Adam



--
You received this message because you are subscribed to the Google Groups "Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to racket-users...@googlegroups.com.

Adam Golding

unread,
Dec 30, 2023, 12:48:10 AM12/30/23
to Racket Users
Reply all
Reply to author
Forward
0 new messages