Giter Site home page Giter Site logo

Comments (3)

svanas avatar svanas commented on June 16, 2024

Everything Delphereum does is async. If you want to approve a token and then wait for the transaction to get mined before you transfer (or do anything else), here is how:

const erc20 = TERC20.Create(client, token);
erc20.ApproveEx(owner, spender, web3.Infinite, procedure(rcpt: ITxReceipt; err: IError)
begin
  if Assigned(err) then
  begin
    // handle error
    EXIT;
  end;
  erc20.TransferEx(owner, blah blah blah, procedure(rcpt: ITxReceipt; err: IError)
  begin
    if Assigned(err) then
    begin
      // handle error
      EXIT;
    end;
    // continue with your next step
  end);
end);

As a general rule, the non-Ex functions -- such as Approve() and Transfer() -- return immediately with a hash of the transaction, while the Ex functions -- such as ApproveEx() and TransferEx() -- wait for the transaction to get mined and then return a receipt of the transaction.

from delphereum.

yonghumeijj avatar yonghumeijj commented on June 16, 2024

Everything Delphereum does is async. If you want to approve a token and then wait for the transaction to get mined before you transfer (or do anything else), here is how:

const erc20 = TERC20.Create(client, token);
erc20.ApproveEx(owner, spender, web3.Infinite, procedure(rcpt: ITxReceipt; err: IError)
begin
  if Assigned(err) then
  begin
    // handle error
    EXIT;
  end;
  erc20.TransferEx(owner, blah blah blah, procedure(rcpt: ITxReceipt; err: IError)
  begin
    if Assigned(err) then
    begin
      // handle error
      EXIT;
    end;
    // continue with your next step
  end);
end);

As a general rule, the non-Ex functions -- such as Approve() and Transfer() -- return immediately with a hash of the transaction, while the Ex functions -- such as ApproveEx() and TransferEx() -- wait for the transaction to get mined and then return a receipt of the transaction.

SendTrans cant do like this. have other way?thanks

from delphereum.

yonghumeijj avatar yonghumeijj commented on June 16, 2024

Everything Delphereum does is async. If you want to approve a token and then wait for the transaction to get mined before you transfer (or do anything else), here is how:

const erc20 = TERC20.Create(client, token);
erc20.ApproveEx(owner, spender, web3.Infinite, procedure(rcpt: ITxReceipt; err: IError)
begin
  if Assigned(err) then
  begin
    // handle error
    EXIT;
  end;
  erc20.TransferEx(owner, blah blah blah, procedure(rcpt: ITxReceipt; err: IError)
  begin
    if Assigned(err) then
    begin
      // handle error
      EXIT;
    end;
    // continue with your next step
  end);
end);

As a general rule, the non-Ex functions -- such as Approve() and Transfer() -- return immediately with a hash of the transaction, while the Ex functions -- such as ApproveEx() and TransferEx() -- wait for the transaction to get mined and then return a receipt of the transaction.

if i want do many step. this way will be very deep.

xxxxx(x,
procedure
begin
yyyyy(y,
procedure
begin
zzzz(z, procedure
begin
end
)
end
);
end;
)

like this more and more deep....

from delphereum.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.