Summary of the invention
The main purpose of the present invention is to provide a kind of token processing methods based on block chain account, computer-readable
Storage medium and electronic equipment, it is intended to solve token information and operate limited technical problem in token contract.
To achieve the above object, the present invention provides a kind of token processing of system account data model based on block chain
Method, the block chain account include user account and contract account, which is characterized in that the token processing method includes:
Token transfer instruction is obtained, the transfer instruction includes the token type and transfer quantity of token to be transferred;
The token to be transferred of the transfer quantity is shifted between contract account and user account;Wherein, user's account
Family and the contract account all can be used for recording token information;The token information includes at least one token type information
With the balance information of the token of respective type.
Preferably, the token transfer instruction is that token removes instruction, described by the to be transferred of the transfer quantity
Token is shifted between contract account and user account
The token remaining sum of token type to be transferred is subtracted into the transfer quantity in contract account, and in user account
The middle token remaining sum by token type to be transferred increases the transfer quantity.
Preferably, the method also includes:
The request of the exchange token of the first user account is obtained, the request for exchanging token includes being exchanged
Token type and quantity;
Obtained token will be exchanged to be stored in the contract account.
Preferably, the token transfer instruction is token shift-in instruction, described by the to be transferred of the transfer quantity
Token is shifted between contract account and user account
The token remaining sum of token type to be transferred is increased into the transfer quantity in the contract account, and described
The token remaining sum of token type to be transferred is subtracted into the transfer quantity in user account.
Preferably, the acquisition token transfer instruction includes: to receive the token transfer instruction from user terminal.
Preferably, the method also includes:
The token for obtaining the first user account produces request, and it includes the token class to be produced that the token, which produces request,
Type and quantity;
If Sorry, your ticket has not enough value by the token of first user account, request and described first is produced according to the token and is used
The token remaining sum of family account generates the token and removes instruction;It includes the token type to be removed that the token, which removes instruction,
And quantity, wherein the token type to be removed is identical with the token type to be produced, the token quantity to be removed
More than or equal to the token quantity to be produced and the difference between the token remaining sum of first user account;
It is instructed, the token of the respective type of respective numbers is transferred to from the contract account described according to the removal
First user account.
Preferably, the method also includes:
The token for obtaining second user account produces request, and it includes the token class to be produced that the token, which produces request,
Type and quantity;
Request, which is produced, according to the token generates token removal instruction;It includes being removed that the token, which removes instruction,
Token type and quantity to be removed wherein the token type to be removed is identical with the token type to be produced
Token quantity is greater than or equal to the token quantity to be produced;
It is instructed, the token of the respective type of respective numbers is transferred to from the contract account described according to the removal
Second user account.
Preferably, the method also includes:
If the second user account does not have pending or ongoing token transaction request, and the second user account
The token remaining sum at family is not zero, then generates token shift-in instruction;The token shift-in instruction includes the token class to be moved into
Type and quantity, wherein the token that token remaining sum is not zero in the token type and the second user account to be moved into
Type is identical, and the token quantity of Yao Yijin is less than or equal to the token remaining sum of the second user account;
It is instructed according to the shift-in, the token of the respective type of respective numbers is transferred to from the second user account
The contract account.
Preferably, the token information is recorded in the extension mapping of the block chain account.
Preferably, before obtaining token transfer instruction, the method also includes:
The block chain account setup is extended and is mapped, the extension mapping is for recording at least one token type letter
The balance information of breath and the token of respective type.
Preferably, the method also includes: if distribution token, corresponding token is stored in the contract account.
Preferably, the token type is to issue the contract address of the contract of the token.
To achieve the above object, the present invention also provides a kind of computer readable storage medium, the computer-readable storages
Media storage has executable program, one or more processor of the executable code is realized described above when executing
Token processing method.
To achieve the above object, the present invention also provides a kind of electronic equipment, the electronic equipment includes memory and processing
Device, the memory are stored with program, and the processor executes described program to realize above-mentioned token processing method.
A kind of token processing method, computer readable storage medium and electricity based on block chain account provided by the invention
Sub- equipment can be such that token is shifted between user account and contract account, when token is transferred in user account
When may make token transaction without being limited to contract, promote transaction performance;Meanwhile token can also be transferred to contract account
Figure spirit completeness is not lost in middle processing.
Specific embodiment
In order to make the objectives, technical solutions, and advantages of the present invention clearer, with reference to the accompanying drawings and embodiments, right
The present invention is further elaborated.It should be appreciated that described herein, specific examples are only used to explain the present invention, not
For limiting the present invention.Based on the embodiments of the present invention, those of ordinary skill in the art are not before making creative work
Every other embodiment obtained is put, shall fall within the protection scope of the present invention.
The description and claims of this application and term " first ", " second ", " third ", " in above-mentioned attached drawing
The (if present)s such as four " are to be used to distinguish similar objects, without being used to describe a particular order or precedence order.It should manage
The data that solution uses in this way are interchangeable under appropriate circumstances, so that the embodiments described herein can be in addition to illustrating herein
Or the sequence other than the content of description is implemented.In addition, term " includes " and " having " and their any deformation, it is intended that
Cover it is non-exclusive include, for example, containing the process, method, system, product or equipment of a series of steps or units need not limit
In step or unit those of is clearly listed, but may include be not clearly listed or for these process, methods, produce
The other step or units of product or equipment inherently.
It should be noted that the description for being related to " first ", " second " etc. in the present invention is used for description purposes only, and cannot
It is interpreted as its relative importance of indication or suggestion or implicitly indicates the quantity of indicated technical characteristic.Define as a result, " the
One ", the feature of " second " can explicitly or implicitly include at least one of the features.In addition, the skill between each embodiment
Art scheme can be combined with each other, but must be based on can be realized by those of ordinary skill in the art, when technical solution
Will be understood that the combination of this technical solution is not present in conjunction with there is conflicting or cannot achieve when, also not the present invention claims
Protection scope within.
The present invention provides processing side token (token) of a kind of system account data model based on block chain and contract
Token information can be moved into block chain account, so that token is operated as primary coin, be handled by method.
A referring to Fig.1, Fig. 1 a are a kind of token processing based on block chain account that first embodiment of the invention provides
Method flow schematic diagram.Wherein, block chain account includes user account (external account) and contract account.Wherein user account is
It is controlled by public key and private key, not store code in user account.Contract account is controlled by the code of account storage, is stored
There is code (opcode).
The address of user account is to be determined by public key, and contract address is determined when intelligent contract is created
(this address is derived by the transaction number that the address and sender of founder send over, this number is usually called
“nonce”)。
It should be noted that user account can be used for recording the token information of user itself preservation, the contract account can
Token information and at least one user for recording contract itself are stored in the token information in contract account;Certain user
The remaining sum of its certain token possessed should be in the token remaining sum and contract account saved in its user account as its preservation
The sum of token remaining sum, such as the token of 100 X types is saved in the user account of certain user, it is the use in contract account
Family saves the token of 50 X types, then the user amounts to the token for possessing 150 X types.
The token processing method includes:
Step S101, obtain token transfer instruction, the transfer instruction include token to be transferred token type and
Shift quantity.
Specifically, please join in conjunction with Fig. 2 is referred to, Fig. 2 is the data structure schematic diagram of transfer instruction.Wherein, in transfer instruction
Token field 10 including recording token type and quantity.
Step S103 will shift the token to be transferred of quantity in contract account and user account according to token transfer instruction
Between shift;Wherein, the user account and the contract account all can be used for recording token information;Token information includes at least
A kind of balance information of token type information and the token of respective type.
Specifically, the token transfer instruction may include that token removes instruction, and step S103 is specifically included: in contract
The token remaining sum of token type to be transferred is subtracted into the transfer quantity in account, and will be to be transferred in user account
The token remaining sum of token type increases the transfer quantity.
Specifically, step S103 is specifically included: by the token remaining sum of token type to be transferred in the contract account
Increase the transfer quantity, and the token remaining sum of token type to be transferred is subtracted into the transfer number in the user account
Amount.
Preferably, token type is to issue the contract address of the contract of token.
In the present embodiment, since token information can recorde in contract account and user account, i.e. token information can be with
It is recorded in block chain account, so that token is quickly searched and modified as primary coin;Token can be shifted according to token
Instruction is shifted in contract account and user account, since the trading activity of the token saved in user account is closed without relying on
It about executes, therefore the performance of token transaction is no longer limited by the performance of contract place block chain, and for there is multiple subregions
For block chain, the token transaction of different subregions can execute parallel, greatly improve transaction performance.Below to be with sudden peal of thunder chain
Example is illustrated: sudden peal of thunder chain initially includes 64 subregions, it is assumed that the contract account for issuing token is located at the 1st subregion, the 2nd subregion
User account A and user account B between initiate a token money transfer transactions, initiated between the user C and user D of the 3rd subregion
One token transaction, then this two transaction can be executed in the 2nd subregion and the 3rd Paralleled respectively.In addition, in the present embodiment
In, it include token type in token transfer process, in transfer instruction, since token type is publication token contract
Contract address, the contract address of each publication token contract are uniquely, to avoid the conflict between different token.
It is a kind of based on block chain account to be that second embodiment provided by the invention provides incorporated by reference to reference Fig. 1 b, Fig. 1 b
The flow diagram of token processing method.The difference of second embodiment and first embodiment is: above-mentioned token processing method
Can also include:
Step S105, obtains the request of the exchange token of the first user account, and the request for exchanging token includes wanting
The token type and quantity of exchange;
Step S107 will exchange obtained token and be stored in contract account.
User can use primary coin (for example, being ether coin in ether mill, sudden peal of thunder chain is chain gram);Or it is other types of
Token exchanges the token of required type, and after exchanging successfully, the token exchanged is first stored in contract account, certainly
User can utilize removal instruction at any time if necessary.
Fig. 3 is please referred to, at a kind of token based on block chain account provided for second embodiment provided by the invention
The flow diagram of reason method.The difference of 3rd embodiment and first embodiment is: before step S101, this method is also wrapped
It includes:
Step S100 extends mapping (map) to the block chain account setup, and the extension mapping is for recording at least one
The balance information of kind token type information and the token of respective type.
It should be noted that the token that contract itself the possesses and token that each user possesses is saved in contract account,
Map can be used specifically to record the token that contract possesses and the token that each user possesses.
It should be noted that user will create corresponding contract account when issuing intelligent contract in block chain
(account), the code (opcode) of intelligent contract is stored in the code field of contract account, and is configured for the contract account
Contract data, i.e. file store (storage), it is preferable that extension mapping map may include in contract data storage.Specifically
Ground, incorporated by reference to referring to Fig. 4, Fig. 4 is the data structure of block chain account.Block chain account setup extension mapping 20, to be used for
Record token information.Token information can store in the blocks chain account such as contract account and user account, so that
The operation of token facilitates as primary coin.
In the present embodiment, due to having carried out extension mapping to block chain with for recording token information, it can be with
Token information is recorded in block chain account.
In some possible embodiments, transfer instruction can be inputted by user terminal.User can be according to oneself need
It asks and produces required token to user account from contract account.For example, user logs in oneself account, the use of user terminal
Corresponding token transfer button is shown in the interface of family, user can be by the input unit of user terminal, for example, mouse, keyboard
Etc. operate the transfer button to input corresponding transfer instruction.
Fig. 5 is please referred to, a kind of processing side token based on block chain account provided for four embodiment of the invention
Method flow diagram.Fourth embodiment different from the first embodiment is that this method further includes below step.
Step S501, the token for obtaining the first user account produce request, and it includes producing that the token, which produces request,
Token type and quantity.
Specifically, it if the first user account carries out producing token transaction to other users account, generates token and produces
Request.
Step S503, if Sorry, your ticket has not enough value by the token of first user account, according to the token produce request and
The token remaining sum of first user account generates the token and removes instruction;It includes removing that the token, which removes instruction,
Token type and quantity to be removed wherein the token type to be removed is identical with the token type to be produced
Token quantity be greater than or equal to difference between the token quantity to be produced and the token remaining sum of first user account
Value.
For example, as user account A will turn 100 tokenX (X represents token type), but user to user account B
The remaining sum of the tokenX of account A only has 70, then at least needs to remove 30 tokenX to user account A from contract account A
In.
Step S505 is instructed according to the removal, and the token of the respective type of respective numbers is turned from the contract account
Move to first user account.
In above-described embodiment, the above method can be determined the need for according to the remaining sum for producing account from contract account transfer
Corresponding token out, to meet transactions demand.
Fig. 6 is please referred to, a kind of token processing method based on block chain account provided for fifth embodiment of the invention
Flow diagram.5th embodiment different from the first embodiment is that this method further includes below step.
Step S601, the token for obtaining second user account produce request, and it includes producing that the token, which produces request,
Token type and quantity.Specifically, it if second user account is traded to other users account, generates token and produces
Request.
Step S603 produces request according to the token and generates token removal instruction;The token removes instruction
The token type and quantity to be removed, wherein the token type to be removed is identical with the token type to be produced,
The token quantity to be removed is greater than or equal to the token quantity to be produced.Preferably, the token quantity to be removed, which is equal to, to be turned
Token quantity out.
Step S605 is instructed according to the removal, and the token of the respective type of respective numbers is turned from the contract account
Move to the second user account.
Fig. 7 is please referred to, Fig. 7 is a kind of processing side token based on block chain account that sixth embodiment of the invention provides
Method flow diagram.Sixth embodiment different from the first embodiment is that this method further includes below step.
Step S707, if the second user account does not have pending or ongoing token transaction request, and described
The token remaining sum of two user accounts is not zero, then generates token shift-in instruction;The token shift-in instruction includes being moved into
Token type and quantity, wherein token remaining sum is not zero in the token type and the second user account to be moved into
Token type it is identical, the token quantity of Yao Yijin is less than or equal to the token remaining sum of the second user account.
Step S709 is instructed according to the shift-in, by the token of the respective type of respective numbers from the second user account
Family is transferred to the contract account.
In the present embodiment, the above method is also used to not trade in user account or when transaction to be processed, will be remaining
Token be transferred in contract account, it can be ensured that the integrality of contract account.
In some possible embodiments, the token processing method further include:
If issuing token, corresponding token is stored in the contract account.
Fig. 8 is please referred to, Fig. 8 is 1 schematic diagram of internal structure of a kind of electronic equipment that first embodiment of the invention provides.The electricity
Sub- equipment 1 includes memory 11, processor 12 and bus 13.
Wherein, memory 11 includes at least a type of readable storage medium storing program for executing, which includes flash memory, hard
Disk, multimedia card, card-type memory (for example, SD or DX memory etc.), magnetic storage, disk, CD etc..Memory 11 exists
It can be the internal storage unit of electronic equipment 1, such as the hard disk of the electronic equipment 1 in some embodiments.Memory 11 is another
It is also possible to the plug-in type hard disk being equipped on the External memory equipment of electronic equipment 1, such as electronic equipment 1 in some embodiments,
Intelligent memory card (Smart Media Card, SMC), secure digital (Secure Digital, SD) card, flash card (Flash
Card) etc..Further, memory 11 can also both include the internal storage unit of electronic equipment 1 or set including external storage
It is standby.Memory 11 can be not only used for the application software and Various types of data that storage is installed on electronic equipment 1, such as intelligent contract machine
The code etc. of program 01 can be also used for temporarily storing the data that has exported or will export.
Processor 12 can be in some embodiments a central processing unit (Central Processing Unit,
CPU), controller, microcontroller, microprocessor or other data processing chips, the program for being stored in run memory 11
Code or processing data, such as execute program 01 etc..
The bus 13 can be Peripheral Component Interconnect standard (peripheral component interconnect, abbreviation
PCI) bus or expanding the industrial standard structure (extended industry standard architecture, abbreviation EISA)
Bus etc..The bus can be divided into address bus, data/address bus, control bus etc..For convenient for indicating, in Fig. 8 only with one slightly
Line indicates, it is not intended that an only bus or a type of bus.
Further, electronic equipment 1 can also include network interface 14, and network interface 14 optionally may include wired connects
Mouth and/or wireless interface (such as WI-FI interface, blue tooth interface), commonly used in being built between the device 1 and other electronic equipments
Vertical communication connection.
Optionally, electronic equipment 1 can also include user interface, and user interface may include display (Display), defeated
Enter unit such as keyboard (Keyboard), optional user interface can also include standard wireline interface and wireless interface.It is optional
Ground, in some embodiments, display can be light-emitting diode display, liquid crystal display, touch-control liquid crystal display and OLED
(Organic Light-Emitting Diode, Organic Light Emitting Diode) touches device etc..Wherein, display can also be appropriate
Referred to as display screen or display unit, for being shown in the information handled in electronic equipment 21 and for showing visual user
Interface.
Fig. 8 illustrates only the electronic equipment 1 with component 11-14 and intelligent contract machine program 01, those skilled in the art
Member may include less or more than illustrating it is understood that the structure shown in Fig. 8 does not constitute the restriction to electronic equipment
More components perhaps combines certain components or different component layouts.
Memory 11 is for storing executable program.The processor 12 is for executing executable program 1 to realize following side
Method.
Token transfer instruction is obtained, the transfer instruction includes the token type and transfer quantity of token to be transferred.
The token to be transferred for shifting quantity is shifted between contract account and user account;Wherein, the user account and
The contract account all can be used for recording token information;Token information includes at least one token type information and respective class
The balance information of the token of type.
Specifically, the token transfer instruction is that token removes instruction, will shift the token to be transferred of quantity in contract
Transfer includes: that the token remaining sum of token type to be transferred is subtracted the transfer in contract account between account and user account
Quantity, and the token remaining sum of token type to be transferred is increased into the transfer quantity in user account.
Specifically, the token transfer instruction is token shift-in instruction, the token transfer instruction is token shifting
Instruction specifically includes out: the token remaining sum of token type to be transferred is increased into the transfer quantity in the contract account,
And the token remaining sum of token type to be transferred is subtracted into the transfer quantity in the user account.
Specifically, token type is to issue the contract address of the contract of token.
In the present embodiment, since token information can recorde in contract account and user account, i.e., in block chain account,
So that token is quickly searched and modified as primary coin, and allow across the chain transaction of token, is held without relying on contract
Row.In addition, in the present embodiment, since token contract address is uniquely, to avoid the conflict between different token.
In some possible embodiments, this method further include:
The block chain account setup is extended and is mapped, the extension mapping is for recording at least one token type letter
The balance information of breath and the token of respective type.
Specifically, extension is mapped as being added to the token field of record token information in block chain account.Such as Fig. 3 institute
Show.
It maps due to having carried out extension to block chain to be used to record token information, token information can be remembered
It records in block chain account.
In some possible embodiments, transfer instruction can be inputted by user terminal.User can be according to oneself need
It asks and produces required token to user account from contract account.
In some feasible implementations, this method further include:
The token for obtaining the first user account produces request, and it includes the token class to be produced that the token, which produces request,
Type and quantity;
If Sorry, your ticket has not enough value by the token of first user account, request and described first is produced according to the token and is used
The token remaining sum of family account generates the token and removes instruction;It includes the token type to be removed that the token, which removes instruction,
And quantity, wherein the token type to be removed is identical with the token type to be produced, the token quantity to be removed
More than or equal to the difference between the token remaining sum of the token quantity and first user account to be produced;
It is instructed, the token of the respective type of respective numbers is transferred to from the contract account described according to the removal
First user account.
In above-described embodiment, the above method can be determined the need for according to the remaining sum for producing account from contract account transfer
Corresponding token out, to meet transactions demand.
In some feasible implementations, this method further includes below step:
The token for obtaining second user account produces request, and it includes the token class to be produced that the token, which produces request,
Type and quantity;
Request, which is produced, according to the token generates token removal instruction;It includes being removed that the token, which removes instruction,
Token type and quantity to be removed wherein the token type to be removed is identical with the token type to be produced
Token quantity is greater than or equal to the token quantity to be produced;
It is instructed, the token of the respective type of respective numbers is transferred to from the contract account described according to the removal
Second user account;
If the second user account does not have pending or ongoing token transaction request, and the second user account
The token remaining sum at family is not zero, then generates token shift-in instruction;The token shift-in instruction includes the token class to be moved into
Type and quantity, wherein the token that token remaining sum is not zero in the token type and the second user account to be moved into
Type is identical, and the token quantity of Yao Yijin is less than or equal to the token remaining sum of the second user account;
It is instructed according to the shift-in, the token of the respective type of respective numbers is transferred to from the second user account
The contract account.
In the present embodiment, the above method is also used to not trade in user account or when transaction to be processed, will be remaining
Token be transferred in contract account.
In some possible embodiments, the token processing method further include:
If issuing token, corresponding token is stored in the contract account.
In the present embodiment, which can be PC (Personal Computer, PC), be also possible to
Smart phone, tablet computer, palm PC, portable computer.
In the above-described embodiments, can come wholly or partly by software, hardware, firmware or any combination thereof real
It is existing.When implemented in software, it can entirely or partly realize in the form of a computer program product.
The computer program product includes one or more computer instructions.Load and execute on computers the computer
When program instruction, the process or function being somebody's turn to do according to the embodiment of the present invention are entirely or partly generated.The computer can be general
Computer, special purpose computer, computer network or other programmable devices.The computer instruction can store in computer
In readable storage medium storing program for executing, or transmit from a computer readable storage medium to another computer readable storage medium, for example,
The computer instruction can from a web-site, computer, server or data center by it is wired (such as coaxial cable,
Optical fiber, Digital Subscriber Line (DSL)) or wireless (such as infrared, wireless, microwave etc.) mode to another web-site, computer,
Server or data center are transmitted.The computer readable storage medium can be any available Jie that computer can store
Matter either includes the data storage devices such as one or more usable mediums integrated server, data center.The usable medium
It can be magnetic medium, (for example, floppy disk, hard disk, tape), optical medium (for example, DVD) or semiconductor medium (such as solid-state
Hard disk Solid State Disk (SSD)) etc..
It is apparent to those skilled in the art that for convenience and simplicity of description, the system of foregoing description,
The specific work process of device and unit, can refer to corresponding processes in the foregoing method embodiment, and details are not described herein.
In several embodiments provided herein, it should be understood that disclosed system, device and method can be with
It realizes by another way.For example, the apparatus embodiments described above are merely exemplary, for example, the unit is drawn
Point, only a kind of logical function partition, there may be another division manner in actual implementation, such as multiple units or components can
To combine or be desirably integrated into another system, or some features can be ignored or not executed.Another point, it is shown or beg for
The mutual coupling, direct-coupling or communication connection of opinion can be through some interfaces, the INDIRECT COUPLING of device or unit
Or communication connection, it can be electrical property, mechanical or other forms.
Unit may or may not be physically separated as illustrated by the separation member for this, show as unit
Component may or may not be physical unit, it can it is in one place, or may be distributed over multiple nets
On network unit.It can select some or all of unit therein according to the actual needs to realize the mesh of this embodiment scheme
's.
It, can also be in addition, each functional unit in each embodiment of the application can integrate in one processing unit
It is that each unit physically exists alone, can also be integrated in one unit with two or more units.Above-mentioned integrated list
Member both can take the form of hardware realization, can also realize in the form of software functional units.
If the integrated unit is realized in the form of SFU software functional unit and when sold or used as an independent product,
It can store in a computer readable storage medium.Based on this understanding, the technical solution of the application substantially or
Person says that all or part of the part that contributes to existing technology or the technical solution can body in the form of software products
Reveal and, which is stored in a storage medium, including some instructions are with so that a computer is set
Standby (can be personal computer, server or the network equipment etc.) execute each embodiment this method of the application whole or
Part steps.And storage medium above-mentioned include: USB flash disk, mobile hard disk, read-only memory (ROM, Read-Only Memory),
Random access memory (RAM, Random Access Memory), magnetic or disk etc. be various to can store program code
Medium.
It should be noted that the serial number of the above embodiments of the invention is only for description, do not represent the advantages or disadvantages of the embodiments.And
The terms "include", "comprise" herein or any other variant thereof is intended to cover non-exclusive inclusion, so that packet
Process, device, article or the method for including a series of elements not only include those elements, but also including being not explicitly listed
Other element, or further include for this process, device, article or the intrinsic element of method.Do not limiting more
In the case where, the element that is limited by sentence "including a ...", it is not excluded that including process, device, the article of the element
Or there is also other identical elements in method.
The above is only a preferred embodiment of the present invention, is not intended to limit the scope of the invention, all to utilize this hair
Equivalent structure or equivalent flow shift made by bright specification and accompanying drawing content is applied directly or indirectly in other relevant skills
Art field, is included within the scope of the present invention.