Using generative artificial intelligence for automated analysis of smart contracts on blockchain
Methods and systems are provided for using generative AI for automated analysis of smart contracts on blockchain. In embodiments described herein, smart contract code for a smart contract is accessed in blockchain via a retriever component. The smart contract code includes a condition of the smart contract in a programming language format. A language model generates natural language content based on the smart contract code. The natural language content is then displayed.
1 . A computer-implemented method comprising:
accessing, via a retriever component, smart contract code in a blockchain or a smart contract code repository for a smart contract, the smart contract code comprising conditions of the smart contract in a programming language format;
generating, by prompting a generative artificial intelligence (AI) language model fine-tuned based on at least one of a subject matter of the smart contract or a business related to the smart contract, natural language content based on the smart contract code, the natural language content comprising natural language descriptions of each of the conditions required for execution of the smart contract, wherein prompting the generative AI language model comprises:
generating, using chain-of-thought prompting, a set of prompts based on the conditions of the smart contract in the programming language format; and
applying the set of prompts to the generative AI language model to generate the natural language content; and
causing display, via a presentation component, of the natural language content, wherein the natural language content comprises a warning related to an off-chain condition of the smart contract code, the off-chain condition corresponding to one of the conditions of the smart contract required to be fulfilled outside a domain of the blockchain in order to execute the smart contract.
2 . The computer-implemented method of claim 1 , wherein the generative AI language model is trained using training data comprising corresponding smart contract code from a public blockchain and corresponding descriptions of the corresponding smart contract code from the public blockchain.
3 . The computer-implemented method of claim 1 , wherein the generative AI language model is a pre-trained language model, and the pre-trained language model is fine-tuned using Low Rank Adaptations (LoRA) by training the pre-trained language model based on training data related to at least one of the subject matter of the smart contract or the business related to the smart contract.
4 . The computer-implemented method of claim 1 , wherein the natural language content comprises a summary of the smart contract, the summary comprising (1) a purpose of the smart contract, (2) parties to the smart contract, (3) payment terms of the smart contract, (4) timeframes of the smart contract, (5) presence or absence of accompanying legal terms for the smart contract, (6) dispute resolution of the smart contract, (7) termination procedures of the smart contract; and (8) compliance requirements of the smart contract.
5 . The computer-implemented method of claim 1 , wherein the natural language content comprises a missing condition from the smart contract code based on a corresponding condition from a related smart contract in training data of the generative AI language model.
6 . The computer-implemented method of claim 1 , wherein the natural language content comprises suggested contract language based on the smart contract corresponding to natural language contract terms of a written contract instrument.
7 . One or more non-transitory computer-readable media having a plurality of executable instructions embodied thereon, which, when executed by one or more processors, cause the one or more processors to perform a method comprising:
accessing, via a retriever component, smart contract code in a blockchain or a smart contract code repository for a smart contract, the smart contract code comprising conditions of the smart contract in a programming language format;
accessing, via the retriever component, terms accompanying the smart contract through smart contract metadata of the smart contract;
generating, by prompting a generative artificial intelligence (AI) language model fine-tuned based on at least one of a subject matter of the smart contract or a business related to the smart contract, natural language content based on the smart contract code and the terms accompanying the smart contract, the natural language content comprising natural language descriptions of each of the conditions required for execution of the smart contract, wherein prompting the generative AI language model comprises:
generating, using chain-of-thought prompting, a set of prompts based on the conditions of the smart contract in the programming language format; and
applying the set of prompts to the generative AI language model to generate the natural language content; and
causing display, via a presentation component, of the natural language content, wherein the natural language content comprises a missing condition from the smart contract code based on a corresponding condition from a related smart contract in training data of the generative AI language model.
8 . The one or more non-transitory computer-readable media of claim 7 , wherein the generative AI language model is trained using the training data comprising corresponding smart contract code from a public blockchain and corresponding descriptions of the corresponding smart contract code from the public blockchain.
9 . The one or more non-transitory computer-readable media of claim 7 , wherein the generative AI language model is a pre-trained language model, and the pre-trained language model is fine-tuned using Low Rank Adaptations (LoRA) by training the pre-trained language model based on corresponding training data related to at least one of the subject matter of the smart contract or the business related to the smart contract.
10 . The one or more non-transitory computer-readable media of claim 7 , wherein the natural language content comprises a summary of the smart contract, the summary comprising (1) a purpose of the smart contract, (2) parties to the smart contract, (3) payment terms of the smart contract, (4) timeframes of the smart contract, (5) presence or absence of accompanying legal terms for the smart contract, (6) dispute resolution of the smart contract, (7) termination procedures of the smart contract; and (8) compliance requirements of the smart contract.
11 . The one or more non-transitory computer-readable media of claim 7 , wherein the natural language content comprises a warning related to an off-chain condition of the smart contract code, the off-chain condition corresponding to one of the conditions of the smart contract required to be fulfilled outside a domain of the blockchain in order to execute the smart contract.
12 . The one or more non-transitory computer-readable media of claim 7 , wherein the natural language content comprises suggested contract language based on the smart contract code.
13 . A computing system comprising:
a processor; and
a non-transitory computer-readable medium having stored thereon instructions that when executed by the processor, cause the processor to perform operations including:
fine-tuning using Low Rank Adaptations (LoRA), via a fine-tuning component, a pre-trained generative artificial intelligence (AI) language model to generate natural language content based on smart contract code using training data related to at least one of a subject matter of a corresponding smart contract or a business related to the corresponding smart contract;
accessing, via a retriever component, corresponding smart contract code in a blockchain or a smart contract code repository for a smart contract, the corresponding smart contract code comprising conditions of the smart contract in a programming language format;
generating, by prompting the pre-trained generative AI language model as fine-tuned, corresponding natural language content based on the corresponding smart contract code, the natural language content comprising natural language descriptions of each of the conditions required for execution of the smart contract, wherein prompting the pre-trained generative AI language model comprises:
generating, using chain-of-thought prompting, a set of prompts based on the conditions of the smart contract in the programming language format; and
applying the set of prompts to the pre-trained generative AI language model to generate the natural language content; and
causing display, via a presentation component, of the corresponding natural language content, wherein the natural language content comprises a warning related to an off-chain condition of the smart contract code, the off-chain condition corresponding to one of the conditions of the smart contract required to be fulfilled outside a domain of the blockchain in order to execute the smart contract.
14 . The computing system of claim 13 , wherein the pre-trained generative AI language model is pre-trained using the training data comprising the smart contract code from a public blockchain and corresponding descriptions of the smart contract code from the public blockchain.
15 . The computing system of claim 13 , wherein the natural language content comprises a summary of the smart contract, the summary comprising (1) a purpose of the smart contract, (2) parties to the smart contract, (3) payment terms of the smart contract, (4) timeframes of the smart contract, (5) presence or absence of accompanying legal terms for the smart contract, (6) dispute resolution of the smart contract, (7) termination procedures of the smart contract; and (8) compliance requirements of the smart contract.